Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tomac4t/ebd83d9b9affeae0875874a54798e7d9 to your computer and use it in GitHub Desktop.
Save tomac4t/ebd83d9b9affeae0875874a54798e7d9 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 https://www.google.com/search*
// @version 0.2.0
// @grant unsafeWindow
// @run-at document-end
// ==/UserScript==
(function () {
var fix_link = (el) => {
if (el.href.indexOf('www.google.') === -1) {
el.removeAttribute('onmousedown');
el.removeAttribute('ping');
el.setAttribute("target", "_blank");
el.setAttribute("rel", "noopener noreferrer");
}
};
var n = document.links.length;
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