DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Google Redirector

03.29.2006
| 3439 views |
  • submit to reddit
        
// ==UserScript==
// @name          Google Redirector
// @namespace     http://d.hatena.ne.jp/youpy/
// @include       *
// ==/UserScript==

(function() {
    var targets = document.evaluate('//a[starts-with(@href, "http")]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
    for (var i = 0; i < targets.snapshotLength; i ++) {
	targets.snapshotItem(i).href = 'http://www.google.com/url?sa=D&q=' + encodeURIComponent(targets.snapshotItem(i).href);
    }
})();