By Howard
—
Last update
Mar 22, 2008
—
Installed
1,612 times.
// ==UserScript==
// @name AutoPrint 3.0
// @namespace http://www.userscripts.org
// @description automatically go to the print version of differnet pages
// @version 3.0
// @date 2007-03-22
// @include *wikipedia.org/wiki*
// @include *nytimes.com*
// @include *washingtonpost.com*
// @include *time.com*
// @include *newsweek.com*
// @include *sfgate.com*
// @include *nydailynews.com*
// @include *rd.com*
// @include *wired.com*
// @include *businessweek.com*
// @include *nypost.com*
// @include *chicagotribune.com*
// @include *tdn.com*
// @include *newsday.com*
// @include *pcworld.com*
// @include *newscientist.com*
// @include *economist.com*
// @include *esquire.com*
// @include *newyorker.com*
// ==/UserScript==
function navDOM(id, path) {
var elem = document.getElementById(id);
for (i=0; i<path.length; i++) {
elem = elem.childNodes[path[i]];
}
return elem;
}
var href = window.location.href;
switch (true) {
case /wikipedia.org\/wiki/.test(href):
var title = href.substring(href.indexOf('wiki/')+5);
var newlink = 'w/index.php?title=' + title + '&printable=yes';
window.location.href = window.location.href.replace('wiki/'+title, newlink);
break;
case /nytimes.com[\D\d]*ref/.test(href) && !/pagewanted=print/.test(href):
window.location.href = href + "&pagewanted=print"
break;
/*
case /latimes.com[\D\d]*./.test(href) && !/print/.test(href):
window.location.href = navDOM('story_utilities', new Array(1,5,0));
break;
*/
case /washingtonpost.com\/wp-dyn\/content\/article/.test(href) && !/_pf.html/.test(href):
window.location.href = href.substring(0,href.indexOf(".html")) + "_pf.html"
break;
case /time.com\/time\/[\D\d]*\/article/.test(href):
window.location.href = navDOM('articleTools', new Array(1,3,0));
break;
case /newsweek.com\/id\/\d*$/.test(href):
window.location.href = href + "/output/print"
break;
case /sfgate.com\/cgi-bin\/article/.test(href) && !/printable/.test(href):
window.location.href = navDOM('contentcol', new Array(9,3,1,0)).href;
break;
case /nydailynews.com[\D\d]*\d*-\d*-\d*/.test(href) && !/print/.test(href):
window.location.href = navDOM('section-b', new Array(1,3,0));
break;
case /rd.com[\D\d]*.html/.test(href):
var temp = String(navDOM('rdIconsUlTop', new Array(3,0)));
temp = temp.substring(temp.indexOf("popWin")+8, temp.indexOf("contentId")+15);
window.location.href = 'http://www.rd.com' + temp;
case /wired.com/.test(href) && !/print/.test(href):
window.location.href = href.replace(/wired.com/, "wired.com/print");
break;
/*
case /menshealth.com\/cda\/article/.test(href) && !/print/.test(href):
alert("HERE");
alert(navDOM('headArea', new Array(9,1)).href);
window.location.href = navDOM('headArea', new Array(9,1)).href;
break;
*/
case /businessweek.com[\D\d]*content/.test(href) && !/print/.test(href):
window.location.href = href.substring(0, href.indexOf("htm")+3).replace(/businessweek.com/, "businessweek.com/print");
break;
case /nypost.com/.test(href) && !/print/.test(href):
window.location.href = "http://www.nypost.com/php/pfriendly/print.php?url=" + href
break;
case /chicagotribune.com[\D\d]*.story/.test(href) && !/print/.test(href):
window.location.href = navDOM('list-box', new Array(3,9,1)).href;
break;
case /tdn.com[\D\d]*.txt/.test(href) && !/prt/.test(href):
window.location.href = href.replace(/.txt/, ".prt");
break;
case /newsday.com[\D\d]*.story/.test(href) && !/print/.test(href):
window.location.href = navDOM('list-box', new Array(3,9,1)).href;
break;
case /pcworld.com[\D\d]*article/.test(href) && !/printable/.test(href):
window.location.href = href.replace(/pcworld.com/, "pcworld.com/printable").replace(/article.html/, "printable.html");
break;
case /newscientist.com\/article/.test(href) && !/print/.test(href):
window.location.href = navDOM('artToolsTop', new Array(1,0)).href;
break;
case /economist.com[\D\d]*story_id/.test(href) && !/PrinterFriendly/.test(href):
window.location.href = navDOM('article_tools', new Array(3,0)).href;
break;
case /esquire.com\/[\D\d]*\/[\D\d]*\//.test(href) && !/print-this/.test(href):
window.location.href = navDOM('article_info_container', new Array(4,1,1,0,1,0)).href;
break;
case /newyorker.com\/reporting/.test(href) && !/printable=true/.test(href):
window.location.href = href + '?printable=true';
break;
}
//www.suntimes.com
//www.luckymag.com
//www.chron.com
//www.ajc.com
var GM_update = function(title, version, updateUrl, versionUrl) {
var title = title;
var today = new Date();
today = today.getDate();
var last = GM_getValue(title);
var current;
var answer;
var updateUrl = updateUrl;
var versionUrl = versionUrl;
this.init = function() {
if(last != undefined) {
if(today - last >= 7 || today - last <= -24) {
GM_setValue(title, today);
this.check();
}
}
else {
GM_setValue(title, today);
this.check();
}
}
this.check = function() {
GM_xmlhttpRequest({
method:"GET",
url:versionUrl,
onreadystatechange:this.finish
});
}
this.finish = function(o) {
if(o.readyState == 4) {
current = o.responseText;
current = current.split(".");
version = version.split(".");
if(version[0] < current[0]) {
answer = confirm("Update " + title + " to version " + current.join(".") + "?");
if(answer) { GM_openInTab(updateUrl); }
}
else if(version[1] < current[1]) {
answer = confirm("Update " + title + " to version " + current.join(".") + "?");
if(answer) { GM_openInTab(updateUrl); }
}
else if(version[2] < current[2]) {
answer = confirm("Update " + title + " to version " + current.join(".") + "?");
if(answer) { GM_openInTab(updateUrl); }
}
else {
// up to date
}
}
}
//start
this.init();
}
GM_update('AutoPrint', '3.0', 'http://userscripts.org/scripts/show/13368', 'http://bettertube.googlepages.com/ap_version.txt');