Skip to content

Instantly share code, notes, and snippets.

@zb3
Last active May 20, 2022 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zb3/e86c90dd018a949be508d33084129a2e to your computer and use it in GitHub Desktop.
Save zb3/e86c90dd018a949be508d33084129a2e to your computer and use it in GitHub Desktop.
RewriteMeNot - a userscript that prevents rewriting of google search result urls, so you can copy them (doesn't really prevent tracking, better extensions exist for that purpose). This is much simpler than other scripts and works only on www.google.com.
// ==UserScript==
// @name RewriteMeNot
// @namespace zb3.rmn
// @include https://www.google.com/*
// @version 1
// @run-at document-end
// ==/UserScript==
// Google can track us anyway, but rewriting search result urls so that we can't even copy them is pure assholery.
// Google should rewrite their behaviour, not urls.
function rewriteMeNot() {
Object.defineProperty(window, 'rwt', {
get: function(){
return function(){};
},
set: function(){}
});
}
function removeConsentWindow() {
const lbDiv = document.getElementById('lb');
if (lbDiv) {
lbDiv.remove();
}
document.documentElement.style.overflow = 'auto';
}
document.addEventListener('DOMContentLoaded', removeConsentWindow);
const script = document.createElement('script');
script.innerHTML = '(function(){'+rewriteMeNot.toString()+';rewriteMeNot();})()';
document.documentElement.appendChild(script);
removeConsentWindow();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment