Last active
August 29, 2019 14:59
-
-
Save SilverEzhik/27ef59d8fda89f9f460a5aeaab05d6dd to your computer and use it in GitHub Desktop.
Fix DuckDuckGo middle click. What the heck is that JavaScript madness?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Fix DuckDuckGo middle click | |
// @description What the heck is that JavaScript madness? | |
// @include https://*duckduckgo.com/* | |
// @version 1 | |
// @grant none | |
// @run-at document-idle | |
// ==/UserScript== | |
function undoClicky() { | |
//console.log("awoo"); | |
//console.log(document.getElementsByClassName("result")); | |
for (let result of document.getElementsByClassName("result")) { | |
//console.log(result); | |
if (result.classList.contains("result--more")) { | |
result.addEventListener("click", undoClicky); | |
result.addEventListener("click", function(){setTimeout(undoClicky, 1000)}); | |
result.addEventListener("click", function(){setTimeout(undoClicky, 5000)}); | |
} else if (!result.classList.contains("middle-click-fixed")) { | |
result.classList.add("middle-click-fixed"); | |
result.outerHTML = result.outerHTML; // this is the best way to get rid of event listeners. no, really. | |
} | |
} | |
} | |
undoClicky(); | |
setTimeout(undoClicky, 500); | |
setTimeout(undoClicky, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment