Google Reader Update Breaks Google Reader Print Button Script

Editorial Note

Okay, Julien has released the official fix only three hours after this post! So ignore my solution below (in fact I will remove the full code) and get over to the script’s home page for the fix.

As you may know from my Google Reader Print Button hack, I’m a big fan of the Google Reader Print Button greasemonkey script. I use it quite often to print feed entries to a format I can use on my PDA (which has no connectivity).

Now, an update to Google Reader has broken the script. I reported this at the script’s home page, but rather than waiting for the fix, I went ahead and fixed it myself. I need that Print Button! Here’s my fix.

Please note, this is an unofficial fix. You should check the script’s home page to see if an official fix has been released and only use the following fix if it hasn’t. I’m sure the script’s author Julien Gilles will provide an official fix in the near future. I’ll put a note at the top of this post when I know it’s been fixed.

Changes To Make The Script Work With Google Reader Update

In order to fix the script, I needed to fix a couple of items. First, I changed the name of several classes referenced, as follows:

  • Line 26: I changed chrome-stream-title to stream-folder-chooser.
  • Line 39: I changed chrome-footer-container to viewer-footer.

I also changed the printButton.innerHTML assignments on line 47 and 54 to use the new HTML that the Updated Google Reader uses.

For the Print button on line 47, I changed:

printButton.innerHTML ='<tbody><tr><td class="btl"></td><td class="btr"></td></tr><tr><td class="bbl"></td><td class="bbr"><div class="button-body-container"><span class="button-body unselectable">Print</span></div></td></tr></tbody>';

to

printButton.innerHTML ='<div role="wairole:button" tabindex="0" class="goog-button goog-button-base unselectable goog-inline-block goog-button-float-left goog-button-tight" id="entries-down"><div class="goog-button-base-outer-box goog-inline-block"><div class="goog-button-base-inner-box goog-inline-block"><div class="goog-button-base-pos"><div class="goog-button-base-top-shadow">&nbsp;</div><div class="goog-button-base-content"><div class="goog-button-body"><div class="text">Print</div><div class="arrow"></div></div></div></div></div></div></div>';

I made a similar change for Print All on line 54.

Bear in mind I can only see the updated Google Reader, so I have to guess how the old version was coded. That’s why the official fix to the script (when it comes) will be better – the original script author will remember what the Google Reader code looked like when he created the script.

The Full Code – Fixed Version Of The Script

I’ve now removed the full code for the fix, as the official script has now been updated. Go get it at the Google Reader Print Button script’s home page.

Hacking The Script

Here are the steps to fix the script (assuming you have installed the script):

  1. Right-Click on the Greasemonkey icon in Firefox
  2. Click Manage User Scripts and a dialog box will open
  3. Select Google Reader Print Button from the list
  4. Click the Edit button (at the bottom of the dialog box)
  5. If asked for the location of a text editor, find one on your hard drive (if you use Notepad, start by looking for C:\Windows\Notepad.exe)
  6. Copy and Paste the entire script from The Full Code section above
  7. Save, Close and click Okay
  8. Refresh (F5) Google Reader to make sure the changes are loaded

If you want to return the script to its default behaviour, go to the Google Reader Print Button script’s official home page and re-install the script.

The Final Word

I fixed this because I need the Google Reader Print Button script. I hope it helps someone else, but I see this as a short term solution until the official fix comes. Make sure you keep an eye on the official home page.

36 responses on “Google Reader Update Breaks Google Reader Print Button Script

  1. Trey

    I tried the updated script from the home page and the Print button is still not showing up for me.

    Is it still working for you? I need this working again!

    -Trey

    1. Stephen Cronin Post author

      Hi Trey,

      I just tried it again and it definitely works for me.

      I guess you could try right-clicking the Greasemonkey icon, choosing Manage User Scripts, and uninstalling the Google Reader Print Button Script, then trying to install it again from the home page.

      Also, you could try clearing your browser cache (Ctrl+F5 in Firefox).

  2. Trey

    I know where the problem is occurring, but I still don’t know why.
    the linksContainer is NULL even though I can find that element after the page loads.
    Could it be a timing issue where the initializePrintButtons() is called before the
    linksContainer is loaded?

    var linksContainer = document.getElementById(‘viewer-footer’);

    if (!linksContainer) {
    GM_log(‘No Container’);

    return;
    }

  3. Trey

    I have confirmed the problem is a race condition like I described above.
    I think you will only see it if you have a lot of feeds to load. Firefox allows the greasemonkey script to execute before Google Reader is finished loading the ‘viewer-footer’ element, and this causes the linksContainer to be null.

    I was able to workaround this by changing the initializePrintButtons to an anonymous function and setting the delay period to 6 seconds, so that the page has time to finish loading. This is a very simple change. Examples are here -> http://diveintogreasemonkey.org/helloworld/code.html

    window.setTimeout(function(){
    var linksContainer = document.getElementById(‘viewer-footer’);

    if (!linksContainer) {
    GM_log(‘!linksContainer’);

    return;
    }
    printButton = document.createElement(‘div’);
    printButton.addEventListener(“click”, function() { greaderPrint(document.getElementById(‘current-entry’)) }, false);

    printButton.innerHTML =’ Print';

    linksContainer.appendChild(printButton);

    printButton2 = document.createElement(‘div’);
    printButton2.addEventListener(“click”, function() { greaderPrint(document.getElementById(‘entries’)) }, false);
    printButton2.innerHTML =’ Print All';
    linksContainer.appendChild(printButton2); }, 6000);

    1. Stephen Cronin Post author

      Hi Trey,

      Thanks for this great information! I didn’t even realise that this could be a problem. It may be worth copying this comment over to the script’s official home page so the author can see this and consider it for future versions.

      It’s also given me some food for thought, as I’m planning some greasemonkey scripts myself… Thanks!

  4. Cecilia Howks@bless you

    Hey! I’ve cheked it yesterday, It worked! Thanks a lot, I’ll use it in my work.
    You have a nice blog. May I visit you oftener?
    Cecilia

  5. Mira @Contemporary Dining Chairs

    Nice of you to set up a script…
    They got it fixed within three hours of you posting?
    Guess that’s why Google is Google.

  6. John@Srednarb Corporate

    @mira,
    the power of journalism and word of mouth is the key to let google understand we are important in their business. Keeping their business free from bug.

  7. Zath@Hi Tech Gadgets

    I would never have even noticed this as I’ve never even used the Print function, is something that people use a lot of with Google Reader? Especially since the introduction of Gears so you can read your news updates offline if needed?

    Good of you to put the time in on this for those that find it useful tho Stephen.

  8. OM@Cheap cars

    I had heard about it some time back and was trying to figure it out. This article was really useful in the sense that it helped me arrive at a conclusion and now I am some what enlightened about it….

  9. Julien Gilles

    Hi,

    I have uploaded a new version. My solution is to add the setTimeout in the test of linkContainer :

       if (!linksContainer) {
          window.setTimeout(function() { initializePrintButtons() }, 1000);
          return;
       }

    So the init function is called in loop until the linkscontainer is loaded.

    A fixed delay of 6 seconds is not a good solution as sometimes the loading can be longer – you can’t be sure of the maximum loading time, and if the loading is very short, you have to wait 6 seconds. Time is money !

  10. sumaiya@NOKIA SIM-LOCK

    I really scared of changing the HTML cause once i did it with my site, and never could fix it for the template and after a week it became perfect

  11. tony@Cheap web hosting.

    Thanks for the update. I like the fact julien even stoped bye with the new fix and told everyone the update is now on the site.

  12. Imran@Celebrity Wallpaper

    this is cool dude. i had been facing some problem with Google reader. now i think i have got the solution here. at last i think i can come up from the problem. thanks for the solution.

  13. anik@Credit Card Tips

    this is just awesome. i had been facing problem with google reader but after applying this code it’s solved. thanks to all who has made this code.

  14. Asif@Symbian Smartphone

    So, looks like everything has been fixed and we don’t need to apply this code anymore. I love google reader too and don’t want it to make a mess.

  15. History of Golf

    If someone sends me a word document i can print it with no problems. However, if I am the creator of the document, I have to hit the manual print button on my printer for every page.

  16. Alyssa@tell a friend script

    This is what I’ve been searching for. Thanks for providing the information. I’ll drop by here always. Ciao!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Anti-Spam Quiz: