Skip to content

Instantly share code, notes, and snippets.

@k-barton
Last active March 7, 2021 13:50
Show Gist options
  • Save k-barton/da45c4d9441d6907a8f7 to your computer and use it in GitHub Desktop.
Save k-barton/da45c4d9441d6907a8f7 to your computer and use it in GitHub Desktop.
Greasemonkey user script: Remove Google's link tracking
// ==UserScript==
// @name Remove Google's link tracking
// @description Removes onmousedown event from external Google links to allow direct links
// @namespace https://gist.github.com/k-barton
// @include http://*.google.*
// @include https://*.google.*
// @version 0.2.1
// @grant unsafeWindow
// @run-at document-end
// ==/UserScript==
(function() {
var fix_link = (el) => {
if (!el.href.includes("www.google.")) {
el.removeAttribute("onmousedown");
el.removeAttribute("ping");
el.setAttribute("rel", "noopener noreferrer");
el.setAttribute("referrerpolicy", "no-referrer");
el.style.backgroundColor = "#FFFFCC";
}
};
var n = document.links.length;
//console.log("remove google tracking: " + n + " links");
for (let i = 0; i < n; ++i)
fix_link(document.links[i]);
}).apply(null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment