Skip to content

Instantly share code, notes, and snippets.

@schmich
Created April 14, 2015 17:11
Show Gist options
  • Save schmich/f01ab557cde744ba029b to your computer and use it in GitHub Desktop.
Save schmich/f01ab557cde744ba029b to your computer and use it in GitHub Desktop.
function clickButtonAt(targetMs) {
if ($('.thebutton-container.denied').length) {
console.error('You must login first.');
return;
}
if ($('.thebutton-container.pressed').length) {
console.error('You have already pressed the button.');
return;
}
var theButton = $('#thebutton');
var monitor = setInterval(function() {
console.log(r.thebutton._msLeft);
var msLeft = r.thebutton._msLeft;
if (msLeft === null || msLeft === undefined || msLeft === 0 || isNaN(msLeft) || !isFinite(msLeft)) {
return;
}
if (r.thebutton._msLeft <= targetMs) {
theButton.click();
clearInterval(monitor);
}
}, 100);
console.log('Waiting to click the button at or below ' + targetMs + 'ms.');
}
clickButtonAt(1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment