Skip to content

Instantly share code, notes, and snippets.

@deyixtan
Last active September 5, 2026 08:50
Show Gist options
  • Select an option

  • Save deyixtan/168fead90b553b3239c77ca87dcb28ea to your computer and use it in GitHub Desktop.

Select an option

Save deyixtan/168fead90b553b3239c77ca87dcb28ea to your computer and use it in GitHub Desktop.
// url: https://arithmetic.zetamac.com/
// example: solve(1);
const solve = (delay) => {
setInterval(() => {
const startDiv = document.getElementsByClassName("start")[0];
const leftDiv = document.getElementsByClassName("left")[0];
const problemSpan = document.getElementsByClassName("problem")[0];
const answerInput = document.getElementsByClassName("answer")[0];
const doesStartDivExists = startDiv != undefined && startDiv.style.display != "none";
const doesLeftDivExists = leftDiv != undefined;
const doesProblemDivExists = problemSpan != undefined;
const doesAnswerDivExists = answerInput != undefined;
if (!doesStartDivExists || !doesLeftDivExists || !doesProblemDivExists || !doesAnswerDivExists)
return;
const secondsLeft = parseInt(leftDiv.textContent.split(": ")[1]);
if (secondsLeft <= 0)
return;
const sanitizedProblem = problemSpan.textContent.replace("÷", "/").replace("×", "*").replace("–", "-");
const generatedAnswer = eval(sanitizedProblem);
answerInput.value = generatedAnswer;
answerInput.dispatchEvent(new Event('input', { bubbles: true }));
}, delay);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment