humanbenchmark https://www.humanbenchmark.com/games
const words = [];
let wrapper;
function obsRoot() {
const ele = document.getElementsByClassName('verbal-memory-test')[0].children[0];
const observer = new MutationObserver((mutations) => mutations.map(mutation => {
const nodes = mutation.addedNodes;
if (nodes.length > 0 && nodes[0].tagName === 'DIV') {
if (nodes[0].getElementsByClassName('word').length > 0) {
wrapper = nodes[0].getElementsByClassName('word')[0].parentNode;
obsWord();
}
}
}));
observer.observe(ele, {
childList: true
});
}
function obsWord() {
const observer = new MutationObserver((mutations) => mutations.map(mutation => {
const nodes = mutation.addedNodes;
if (nodes.length > 0 && nodes[0].className && nodes[0].className.search('word') !== -1) {
const currentWord = nodes[0].textContent;
setTimeout(() => {
const buttons = document.getElementsByClassName('actions')[0].children;
if (words.indexOf(currentWord) !== -1) {
buttons[0].click();
} else {
words.push(currentWord);
buttons[1].click();
}
}, 1000);
}
}));
observer.observe(wrapper, {
childList: true
});
}
obsRoot();
const ele = document.getElementsByClassName('fill')[0];
const mouseDownEvent = document.createEvent('MouseEvents');
mouseDownEvent.initEvent('mousedown', true, true);
const observer = new MutationObserver((mutations) => mutations.map(mutation => {
const nodes = mutation.removedNodes;
if (nodes.length > 0 && nodes[0].textContent.search('green') !== -1) {
setTimeout(() => ele.dispatchEvent(mouseDownEvent), 94);
}
}));
observer.observe(ele, {
childList: true
});
let answer = 0;
const ele = document.getElementsByClassName('number-memory-test')[0].children[0];
const observer = new MutationObserver((mutations) => mutations.map(mutation => {
const nodes = mutation.addedNodes;
if (nodes.length > 0 && nodes[0].tagName === 'DIV') {
if (nodes[0].textContent.match(/[0-9]{1,}/)) {
answer = nodes[0].textContent;
}
if (nodes[0].getElementsByTagName('input').length > 0) {
const input = nodes[0].getElementsByTagName('input')[0];
input.value = answer;
input.dispatchEvent(changeEvent);
setTimeout(() => input.parentNode.parentNode.dispatchEvent(submitEvent), 1000);
}
if (nodes[0].className.search('showanswer') !== -1) {
setTimeout(() => nodes[0].getElementsByTagName('a')[0].click(), 1000);
}
}
}));
observer.observe(ele, {
childList: true
});
const changeEvent = document.createEvent("HTMLEvents");
changeEvent.initEvent("change", false, true);
const submitEvent = new Event('submit', {
'bubbles': true, // Whether the event will bubble up through the DOM or not
'cancelable': true // Whether the event may be canceled or not
});
const mouseDownEvent = document.createEvent('MouseEvents');
mouseDownEvent.initEvent('mousedown', true, true);
let activeSquares = [];
function obsRoot() {
const root = document.getElementsByClassName('squares')[0];
const rootObserver = new MutationObserver((mutations) => mutations.map(mutation => {
obsSquares();
}));
rootObserver.observe(root, {
childList: true
});
}
function obsSquares() {
const squares = [].slice.call(document.getElementsByClassName('square'));
let observer;
squares.map((square, key) => {
observer = new MutationObserver((mutations) => mutations.map(mutation => {
if (mutation.target.classList.contains('active')) {
activeSquares.push(square);
}
}));
observer.observe(square, {
attributes: true,
attributeFilter: ['class']
});
});
setInterval(() => {
activeSquares = [].concat(uniqEs6(activeSquares));
if (!squares.some(square => square.className.search('active') !== -1)) {
activeSquares.map((square, key) => {
square.dispatchEvent(mouseDownEvent);
if (key === activeSquares.length - 1) activeSquares = [].concat([]);
});
}
}, 5000);
}
var uniqEs6 = (arrArg) => {
return arrArg.filter((elem, pos, arr) => {
return arr.indexOf(elem) == pos;
});
};
obsRoot();
obsSquares();