Skip to content

Instantly share code, notes, and snippets.

@norcalli
Last active August 29, 2015 14:18
Show Gist options
  • Save norcalli/bc7fb4f7b451e6d6819e to your computer and use it in GitHub Desktop.
Save norcalli/bc7fb4f7b451e6d6819e to your computer and use it in GitHub Desktop.
Button presser
var tens_el = document.getElementById("thebutton-s-10s");
var secs_el = document.getElementById("thebutton-s-1s");
var secs = function() { return 10*+tens_el.innerText + +secs_el.innerText; }
var b = document.getElementById("thebutton");
function pressIt() { b.click(); }
function tooLate() {
var t = new Date();
t.setSeconds(t.getSeconds() + 2)
return t.getDate() == 2;
}
var it;
function checkIt() {
if (secs() <= 55 || tooLate()) {
console.log("I PUSHED IT: ALERT, I PUSHED IT. FUCK I DID IT.");
pressIt();
clearInterval(it);
}
}
it = setInterval(checkIt, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment