Skip to content

Instantly share code, notes, and snippets.

@ipetropolsky
Last active April 7, 2020 14:52
Show Gist options
  • Select an option

  • Save ipetropolsky/b8153457c1311af7874dd276eee3c0e4 to your computer and use it in GitHub Desktop.

Select an option

Save ipetropolsky/b8153457c1311af7874dd276eee3c0e4 to your computer and use it in GitHub Desktop.
Hack reaction time
// https://www.humanbenchmark.com/tests/reactiontime
var timeout;
var wait = false;
var el = document.querySelector('.test-standard');
var check = function() {
console.log('Working...');
if (wait && el.classList.contains('view-go')) {
wait = false;
console.log('Fire!!!');
el.dispatchEvent(new MouseEvent('mousedown', {
'view': window,
'bubbles': true,
'cancelable': true
}));
el.dispatchEvent(new MouseEvent('mouseup', {
'view': window,
'bubbles': true,
'cancelable': true
}));
el.dispatchEvent(new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true
}));
}
if (!wait && el.classList.contains('view-waiting')) {
wait = true;
console.log('Start!');
}
timeout = window.setTimeout(check, 75 + Math.random() * 50);
}
check();
// clearTimeout(timeout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment