Skip to content

Instantly share code, notes, and snippets.

@GHolk
Created June 15, 2021 13:46
Show Gist options
  • Save GHolk/bcd03fbb3d22685bfc9657d5c9059ce8 to your computer and use it in GitHub Desktop.
Save GHolk/bcd03fbb3d22685bfc9657d5c9059ce8 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name google search unredirect
// @namespace http://gholk.github.io/
// @version 6
// @match https://www.google.com/search?*
// @grant none
// ==/UserScript==
function unlistenClick() {
for (const a of document.querySelectorAll('a[onmousedown]')) {
a.removeAttribute('onmousedown')
a.removeAttribute('onclick')
}
}
const observer = new MutationObserver(mulist => {
for (const mutation of mulist) {
if (mutation.type == 'childList') {
node = mutation.target
if (node.matches('#taw *, #res *, #rhs *')) {
unlistenClick()
}
}
}
})
observer.observe(document.getElementById('rcnt'), {
childList: true,
subtree: true
})
unlistenClick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment