Created
December 4, 2012 04:02
-
-
Save bennettmcelwee/4200460 to your computer and use it in GitHub Desktop.
Google link cleaner
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 link cleaner | |
// @description Make Google SERPs links go straight to their target, not via Google | |
// @include https://www.google.com/* | |
// @namespace http://thunderguy.com/ | |
// @author Bennett McElwee, bennett@thunderguy.com | |
// ==/UserScript== | |
/* | |
When you click a link in a Google SERPs page, JavaScript redirects you to Google (to | |
track the click) before redirecting you to the actual page. This script disables that | |
behaviour so that you cna get where you're going just that little bit faster. | |
*/ | |
// Chrome-compatible script injection: http://stackoverflow.com/a/8890387/61754 | |
var main = function () { | |
// Wait for current scripts to execute before disabling the mousedown handlers on the links. | |
// It doesn't work if you try to do it immediately. | |
window.setTimeout(function() { | |
var links = document.querySelectorAll(".r a"); | |
for (var i = 0; i < links.length; ++i) { | |
links[i].onmousedown = null; | |
// console.log(links[i].onmousedown); | |
} | |
}, | |
0); | |
}; | |
// Inject the main script | |
var script = document.createElement("script"); | |
script.textContent = "(" + main.toString() + ")();"; | |
document.body.appendChild(script); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this works well, based on https://stackoverflow.com/a/43037561/883015