Skip to content

Instantly share code, notes, and snippets.

@iBug
Last active February 4, 2025 15:41
Show Gist options
  • Select an option

  • Save iBug/5e0370cbf5f399b3029b8802561c77bc to your computer and use it in GitHub Desktop.

Select an option

Save iBug/5e0370cbf5f399b3029b8802561c77bc to your computer and use it in GitHub Desktop.
Telegram Game Bot "Math Battle" solution
function do_math() {
var x = parseInt(document.getElementById("task_x").innerText);
var y = parseInt(document.getElementById("task_y").innerText);
var z = parseInt(document.getElementById("task_res").innerText);
var op = document.getElementById("task_op").innerText;
var Z;
if (op === "+")
Z = x + y;
else if (op === "–") // Trap
Z = x - y;
else if (op === "×") // Trap
Z = x * y;
else if (op === "/")
Z = x / y;
else
Z = 0; // Give up
var score = parseInt(document.getElementById("score_value").innerText);
if ((z === Z) ^ (score >= 1000))
document.getElementById("button_correct").click();
else
document.getElementById("button_wrong").click();
}
setInterval(do_math, 100);
@batryzhan

Copy link
Copy Markdown

how to run it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment