Printer Friendly Redirect

By znerp Last update May 13, 2007 — Installed 1,810 times. Daily Installs: 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0

Archived Comments (locked)

Subscribe to Archived Comments 24 posts, 9 voices

Jesse Andrews Admin

The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)

 
znerp Script's Author

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.

 
dingar Scriptwright

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...

 
znerp Script's Author

UPDATE: now works for newscientist.com

 
znerp Script's Author

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!

 
dingar Scriptwright

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

 
parallel lines Scriptwright

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?

 
znerp Script's Author

UPDATE: now works for boston.com

 
znerp Script's Author

UPDATE: now works for citypaper.net

 
znerp Script's Author

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

 
Robert Litzke Scriptwright

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

 
znerp Script's Author

UPDATE: now works for sun-sentinel.com

 
znerp Script's Author

UPDATE: now works for wral.com.

 
znerp Script's Author

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

 
znerp Script's Author

UPDATE: now works for startribune.com.

 
znerp Script's Author

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

 
meno like-bu... User

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

 
Webb Scriptwright

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.

 
znerp Script's Author

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.

 
Webb Scriptwright

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.

 
znerp Script's Author

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.

 
Junk Blocker Scriptwright

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.

 
znerp Script's Author

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.

 
alien_scum Scriptwright

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?

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel