-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhumanvisualmemory.js
More file actions
35 lines (27 loc) · 871 Bytes
/
humanvisualmemory.js
File metadata and controls
35 lines (27 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// https://humanbenchmark.com/tests/memory
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent('mousedown', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
var StartBtn = document.querySelector("button:nth-child(1)");
var windowsActiveMemory = [];
var curActiveMemory;
function run() {
// Start the memory challenge
StartBtn.dispatchEvent(evt);
setInterval(() => {
checkAndClick();
updateNewMemory();
}, 50);
}
function checkAndClick() {
if (windowsActiveMemory.length > 0) {
for (var i = 0; i < windowsActiveMemory.length; i++) {
windowsActiveMemory[i].dispatchEvent(evt);
}
windowsActiveMemory = [];
}
}
function updateNewMemory() {
curActiveMemory = document.getElementsByClassName("active css-hqmwod");
windowsActiveMemory = Array.from(curActiveMemory);
}
run();