Skip to content

Instantly share code, notes, and snippets.

@kobachi
Last active July 6, 2021 02:04
Show Gist options
  • Save kobachi/e34f8840efe2881188f8e6490c3afb9d to your computer and use it in GitHub Desktop.
Save kobachi/e34f8840efe2881188f8e6490c3afb9d to your computer and use it in GitHub Desktop.
Google Search Tracking Remover
// ==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);
})();
@kobachi
Copy link
Author

kobachi commented Jul 2, 2021

Use this link to install this user script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment