Skip to content

Instantly share code, notes, and snippets.

@marvyn
Last active August 25, 2021 07:34
Show Gist options
  • Save marvyn/c1b73fd00b1fc716080c15fed8e11919 to your computer and use it in GitHub Desktop.
Save marvyn/c1b73fd00b1fc716080c15fed8e11919 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Remove Google Results Redirect
// @namespace Smiths
// @description 9 lines of code to remove all link redirection on Google Search Results. Prevents tracking and helps load times!
// @include http://google.*/search*
// @include https://google.*/search*
// @include http://www.google.*/search*
// @include https://www.google.*/search*
// @include http://www.google.*/webhp*
// @include https://www.google.*/webhp*
// @grant unsafeWindow
// @version 2.0
// ==/UserScript==
if(unsafeWindow.top == unsafeWindow.self){
document.addEventListener('DOMNodeInserted', function(e) {
window.setTimeout(function() {
var rl = document.querySelectorAll('a[target="_blank"]:not([class])');
for (var i = 0; i < rl.length; i++) {
rl[i].removeAttribute('rel');
rl[i].removeAttribute('onmousedown');
rl[i].removeAttribute('data-jsarwt');
rl[i].removeAttribute('data-usg');
rl[i].removeAttribute('data-ved');
}
var rl2 = document.querySelectorAll('a[onmousedown*="return rwt"]');
for (var l = 0; l < rl2.length; l++) {
rl2[l].removeAttribute('rel');
rl2[l].removeAttribute('onmousedown');
rl2[l].removeAttribute('data-jsarwt');
rl2[l].removeAttribute('data-usg');
rl2[l].removeAttribute('data-ved');
}
}, 250);
}, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment