Fork Copy if (observer) { observer.disconnect(); } var running = true; var taskNode = document.getElementById('task'); var taskX = document.getElementById('task_x'); var taskOp = document.getElementById('task_op'); var taskY = document.getElementById('task_y'); var taskRes = document.getElementById('task_res'); var buttonCorrect = document.getElementById('button_correct'); var buttonWrong = document.getElementById('button_wrong'); function isCorrect() { const expression = `${taskX.innerText}${taskOp.innerText}${taskY.innerText}`.replace('×', '*').replace('–', '-') return eval(expression)==taskRes.innerText; } function autoClick() { if (isCorrect()) { buttonCorrect.click(); } else { buttonWrong.click(); } } var config = { attributes: true, childList: true, subtree: true }; var timeoutId = null var observer = new MutationObserver((mutationList) => { if (!running) { return; } for (const mutation of mutationList) { if (mutation.type == 'attributes') { return; } } clearTimeout(timeoutId); setTimeout(() => { autoClick() }, 100) }); // Start observing the target node for configured mutations observer.observe(taskNode, config); function stop() { running = false; } function play() { running = true; autoClick(); }