By arantius
—
Last update
Oct 6, 2005
—
Installed
585 times.
// ==UserScript==
// @name PrivaSuite
// @namespace http://www.arantius.com/misc/greasemonkey/
// @description A suite of (primarily) privacy related tools. A combination of my Blank Target, Straight Click, and Status Saver scripts.
// So it's not really a "privacy" suite .. but they all act on links, so I grouped them up for efficiency!
// @include *
// ==/UserScript==
//
// Originally written by Anthony Lieuallen of http://www.arantius.com/
// Licensed for unlimited modification and redistribution as long as
// this notice is kept intact.
//
// If possible, please contact me regarding new features, bugfixes
// or changes that I could integrate into the existing code instead of
// creating a different script. Thank you
//
(function () {
//various things we need
var href=null, uhref=null, start=null, end=null, j=0;
var atGoogSearch=true&&document.location.href.match(/www.google.com\/search/);
//find all links as a snapshot
var res = document.evaluate("//a",
document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
var i, el;
//iterate over all elements
for (i=0; el=res.snapshotItem(i); i++) {
//blank target
if ('_blank'==el.getAttribute('target')) {
el.removeAttribute('target');
}
//status saver
if (String(el.onmouseover).match(/window\.status/)) {
el.removeAttribute('onmouseover');
el.removeAttribute('onmouseout');
}
//straight click
if (j++>500) return; //failsafe against infinite loops, arbitrary limit
//special case to allow links to google cache through
if (el.href.match(/\/search\?q=cache/)) continue;
//special case for google search. rewriting links on click, EVIL !!!
if (atGoogSearch) el.removeAttribute('onmousedown');
//grab the link and strip off the protocol in front
href=el.href;
if ('http://'!=href.substr(0, 7)) continue;
href=href.substr(7);
//if there's no other link embedded in this link, forget it
uhref=unescape(href);
start=uhref.indexOf('http:');
if (-1==start) start=uhref.indexOf('www.');
if (0>=start) continue;
//at this point we've found a new sub link, grab it out
//(re-evaluate on non-unescaped string)
start=href.indexOf('http');
if (-1==start) start=href.indexOf('www.');
if (0>=start) continue;
href=href.substr(start);
if (href.indexOf('&')>0) href=href.substr(0, href.indexOf('&'));
href=unescape(href);
if ('http://'==href.substr(0, 7)) href=href.substr(7);
//permit links that contain sub-links to the same domain we're at
var host=href.substr(0, href.indexOf('/'));
if (-1!=host.indexOf(':')) host=host.substr(0, host.indexOf(':'));
if (host==document.location.host) continue;
//rewrite this link
//dump('Rewrote: '+el.href+'\nTo: http://'+href+'\n');
el.href='http://'+href;
//in case this new link has a sub-link, decrement i so it gets re-evaluated
i--;
}
})();