Last active
April 7, 2020 14:52
-
-
Save ipetropolsky/b8153457c1311af7874dd276eee3c0e4 to your computer and use it in GitHub Desktop.
Hack reaction time
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
| // 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