Last active
July 6, 2021 02:04
-
-
Save kobachi/e34f8840efe2881188f8e6490c3afb9d to your computer and use it in GitHub Desktop.
Google Search Tracking Remover
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 Tracking Remover | |
// @description Remove click tracking from Google search result | |
// @namespace kobachi.dev | |
// @version 1.2 | |
// @include https://www.google.co*/search* | |
// @include http://www.google.co*/search* | |
// ==/UserScript== | |
(function(){ | |
function removeLinkTracking() { | |
Array.from(document.querySelectorAll("a[href^=http]")).forEach(function(a){ | |
var c = a.cloneNode(true); | |
c.removeAttribute("ping"); | |
c.setAttribute("rel", "noopner noreferrer"); | |
c.addEventListener("click", e => e.stopPropagation()); | |
c.addEventListener("mousedown", e => e.stopPropagation()); | |
Array.from(c.attributes) | |
.map(a => a.name) | |
.filter(a => a.indexOf("on") == 0 || a.indexOf("data-") == 0) | |
.forEach(a => { | |
c.removeAttribute(a); | |
}); | |
a.parentNode.replaceChild(c, a); | |
}); | |
} | |
setTimeout(removeLinkTracking, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this link to install this user script.