Printer Friendly Redirect

Last update on May 13, 2007

Redirects to printer friendly pages if it can find one. A printer icon appears in the corner of such pages. Clicking it turns on the redirect. Clicking again turns it off. Printer friendly pages are cleaner than articles and not on multiple pages.

When it detects that there is a printer friendly version to a page, a small printer is displayed in the top right, which is clickable to change the preference so it will go to the printer friendly page automatically. Similarly, when on a printer friendly page, the printer is displayed and is clickable to disable the preference to redirect for that website in the future.

The size of the printer icon is customisable, just look at the top few lines of code for details of how to change it.

Any suggestions for changes or other comments would be welcome in the comments!

Changelog

UPDATE (27-April-2007): Back button problem now fixed, thanks parallel lines.
UPDATE (26-April-2007): Managed to put an extra close bracket in on the last update and not notice. Fixed this now.
UPDATE (24-April-2007): Grey bar across top of BBC news no longer on top of printer icon.

Summary of Earlier Changes

  • Printer image slightly larger, also fixed in top right.
  • No longer a pop-up box, just a small printer icon in the top corner.
  • Remembers which websites to redirect on.
  • KNOWN ISSUE: If values are reset in about:config instead of toggled, it no longer works for that page until firefox is restarted.

Did this script help you? Please donate, but don't feel forced to! Make payments with PayPal - it's fast, free and secure!




You could comment on this script if you were logged in.

23 comments Feed-icon

1 point
login to vote
znerp script's author
Posted May 14, 2007

dingar, I am aware of problems such as this, but this script isn't the most sophisticated script in the world. My aim has been to ensure that it will redirect on most pages that have a print friendly version, not to ensure that it won't on pages selling printers etc. Without spending a very long time trying to find a way around this issue, it would be impossible to fix this particular problem. I guess this is just the problem with trying to write a script for every page on the internet.

I guess all I can suggest is to hit the printer again if you end up on a page that you don't expect to be on, and manually look for a printer friendly link.

1 point
login to vote
dingar scriptwright
Posted May 13, 2007

Znerp, thank you for your reply. I love this script.
Look PCWorld please, it will jump to a page talk about priter. Such as
http://www.pcworld.com/article/id,130869-page,1...

1 point
login to vote
znerp script's author
Posted May 13, 2007

UPDATE: now works for newscientist.com

1 point
login to vote
znerp script's author
Posted May 10, 2007

dingar, on the whole I've tried to avoid using javascript links, and very few sites seem to use them. On the whole when clicking them, I've found that it attempts to actually send the page to a printer and it would be annoying to have that pop up every time. I know it would be possible to block this from happening, but I'm happy to have the site load for most of the major news sites as it does.

I looked at the site that you linked, and I've found the link you're referring to, but not being familiar with Chinese and due to the reasons listed above, I don't think I'll add it to the script. Feel free though to add as many extra lines as you like to your version though, half the fun of some scripts is customising them for your own use. Glad you like the script though!

1 point
login to vote
dingar scriptwright
Posted May 9, 2007

Look this page
http://news.sina.com.cn/c/2007-03-07/1704124555...
and I add
allLinks[i].href.match("javascript:LoadPrintJs()") ||

1 point
login to vote
parallel lines scriptwright
Posted Apr 27, 2007

i love this script! but i cant get it to go back to the page i came from, it keeps taking me back to the print friendly page. what gives?

1 point
login to vote
znerp script's author
Posted Apr 22, 2007

UPDATE: now works for boston.com

1 point
login to vote
znerp script's author
Posted Apr 22, 2007

UPDATE: now works for citypaper.net

1 point
login to vote
znerp script's author
Posted Apr 21, 2007

Thanks for the feedback Robert Litzke. I've grown the printer icon, and made it easily customisable from the top of the source file.

1 point
login to vote
Robert Litzke scriptwright
Posted Apr 20, 2007

Works well, but the icon could be a bit larger... it's like 10x10 pixels, hard to notice.

1 point
login to vote
znerp script's author
Posted Apr 19, 2007

UPDATE: now works for sun-sentinel.com

1 point
login to vote
znerp script's author
Posted Apr 12, 2007

UPDATE: now works for wral.com.

1 point
login to vote
znerp script's author
Posted Apr 6, 2007

UPDATE: now works for uk.news.yahoo.com

1 point
login to vote
znerp script's author
Posted Apr 2, 2007

UPDATE: now works for startribune.com.

1 point
login to vote
znerp script's author
Posted Mar 31, 2007

UPDATE: now works for news.com and nytimes.com. Thanks for the feedback, meno.

1 point
login to vote
Posted Mar 31, 2007

hmmm...didn't seem to work on news.com or nytimes.com for me

1 point
login to vote
Webb user
Posted Mar 19, 2007

Thanks, znerp.

I prefer the whitelist because I already have my favorite news and entertainment sites hacked with css and I seldom need to bother with printer friendly versions.

1 point
login to vote
znerp script's author
Posted Mar 19, 2007

As it is, you can cut a lot out of it if that's how you'd like to use it. I'd suggest keeping it as-is for a few days though, because the box only pops up once per host, so after a while you'll see it much much less. That said, you'd want to make the code simply...

      var allLinks = document.getElementsByTagName('a');
      if (document.location.href.match("print") == null) {
        for (var i = 0; i < allLinks.length; i++) {
          if (allLinks[i].href.match("print.html") ||
              allLinks[i].href.match("print.shtml") ||
              allLinks[i].href.match("/print/") ||
              allLinks[i].href.match("/printer_friendly_story/") ||
              allLinks[i].href.match("&pagewanted=print") ||
              allLinks[i].href.match("/print?") ||
              allLinks[i].href.match("type=printable") ||
              allLinks[i].href.match("&printer=1")) {
            document.location = allLinks[i].href;
          }//if (allLin...
        }//for (var i ...
      }//if (docume...
      

... to get what you asked for.

1 point
login to vote
Webb user
Posted Mar 19, 2007

I really like this but I hate the popup box. Can you show me what to remove to get rid of it?

I'd rather edit the includes from the universal http:/ /* to my own whitelist.

1 point
login to vote
znerp script's author
Posted Mar 18, 2007

sorry, Junk Blocker, I can't seem to roll that into this script well, and it didn't seem to work for me, so I've made simple redirect just for wired.com ... it seems to work in all the articles I tried; it's at http://userscripts.org/scripts/show/7999. I'm not familiar with wired.com at all, so forgive me if I've made a glaring oversight. Both scripts ought to work well together.

1 point
login to vote
Junk Blocker scriptwright
Posted Mar 18, 2007

For wired.com, the logic is something like this:

      if (document.location.hostname.match(/wired\.com$/) && document.location.href.match(/.\.html/) && !document.location.href.match(/_pr\.html/)) {
        var newurl = document.location.href.replace(/\.html/, '_pr.html');
        document.location = newurl;
        return;
      }
      

if you wanna roll that up into the script.

1 point
login to vote
znerp script's author
Posted Mar 18, 2007

actually, yeah, I've done that. I'm an issue with it that I'm trying to work out before uploading it. The only way that I can see of doing this is by using GM_setValue, and these can be changed easily in about:config, but would take me more time than I want to spend at the moment to devise a more elaborate way of changing them. The issue I'm having is that it all works as expected, but if I reset the value in about:config, it throws a hissy fit and won't work. I think I'm doing something wrong in the GM_getValue, but I don't know what.

1 point
login to vote
alien_scum scriptwright
Posted Mar 18, 2007

Sweet script, makes reading the news on-line so much better, but that pop-up is starting to piss me off have you considered getting it to remember what you said for each domain?

You could comment on this script if you were logged in.