Skip to content

Instantly share code, notes, and snippets.

@codegoalie
Created February 16, 2021 21: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 codegoalie/a5abdbbf3e6356efd996986a104cbbb1 to your computer and use it in GitHub Desktop.
Save codegoalie/a5abdbbf3e6356efd996986a104cbbb1 to your computer and use it in GitHub Desktop.
Disable instapage buttons for a few seconds
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