-
-
Save JasonC761/c7c130f35b3bee56acf9013b2713a5b6 to your computer and use it in GitHub Desktop.
Google Search Unmangler - Greasemonkey Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Google Search Unmangler | |
// @namespace ScrewGoogle | |
// @description Unmangle Google Search URLs | |
// @include http://google.tld/* | |
// @include http://www.google.tld/* | |
// ==/UserScript== | |
var ScrewGoogle = {}; | |
ScrewGoogle.unmangleURL = function(url) { | |
var urlIndex = url.indexOf("url="), lastParam, unmangled; | |
if (urlIndex == -1) { | |
return url; | |
} | |
urlIndex += 4; | |
unmangled = url.substr(urlIndex); | |
lastParam = unmangled.indexOf('&'); | |
unmangled = decodeURIComponent(unmangled.substring(0, lastParam)); | |
return unmangled; | |
}; | |
ScrewGoogle.findMangledURLs = function() { | |
var links = document.getElementsByClassName("l"), link, attrs; | |
for (var i = 0, ii = links.length; i < ii; ++i) { | |
link = links[i]; | |
attrs = link.attributes; | |
for (var attr in attrs) { | |
if (attr == "href" || attr == "class") { | |
continue; | |
} | |
link.removeAttribute(attr); | |
} | |
link.setAttribute('href', ScrewGoogle.unmangleURL(link.href)); | |
} | |
}; | |
window.addEventListener("load", function(e) { | |
unsafeWindow.rwt = function(){}; | |
ScrewGoogle.findMangledURLs(); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment