Created
February 16, 2021 21:18
-
-
Save codegoalie/a5abdbbf3e6356efd996986a104cbbb1 to your computer and use it in GitHub Desktop.
Disable instapage buttons for a few seconds
This file contains hidden or 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
const buttonDelaySeconds = 5; | |
const selector = ".btn.url-link"; | |
function run() { | |
var els = document.querySelectorAll(selector); | |
var origHrefs = []; | |
els.forEach(function (el) { | |
origHrefs.push(el.href); | |
el.style["pointer-events"] = "none"; | |
el.style.opacity = 0.2; | |
}); | |
setTimeout(function () { | |
els.forEach(function (el, i) { | |
el.href = origHrefs[i]; | |
el.style["pointer-events"] = ""; | |
el.style.opacity = 1; | |
}); | |
}, buttonDelaySeconds * 1000); | |
} | |
if (document.readyState != "loading") run(); | |
else if (document.addEventListener) | |
document.addEventListener("DOMContentLoaded", run); | |
else | |
document.attachEvent("onreadystatechange", function () { | |
if (document.readyState == "complete") run(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment