Last active
December 23, 2016 21:53
-
-
Save Nhoya/76acb1bbfc9dd1b2fdf7f830fbcd8822 to your computer and use it in GitHub Desktop.
Telegram Math Battle Game Solver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solver(){ | |
var num1 = Number(document.getElementById('task_x').innerHTML); | |
var num2 = Number(document.getElementById('task_y').innerHTML); | |
if( oldnum1 !== num1 || oldnum2 !== num2){ | |
var operation = document.getElementById('task_op').innerHTML; | |
var fake_result = document.getElementById('task_res').innerHTML; | |
var result = true; | |
if (operation === '×'){ | |
result = (num1 * num2); | |
} | |
if (operation === '+'){ | |
result = (num1 + num2); | |
} | |
if (operation === '–'){ | |
result = (num1 - num2); | |
} | |
if (operation === '/'){ | |
result = (num1 / num2); | |
} | |
if (result == fake_result){ | |
console.log(num1 + operation + num2 + "=" +result + " " + "true"); | |
document.getElementById('button_correct').click(); | |
} | |
else{ | |
console.log(num1 + operation+ num2 + "=" +result + " " +"false"); | |
document.getElementById('button_wrong').click(); | |
} | |
oldnum1 = num1; | |
oldnum2 = num2; | |
} | |
} | |
var oldnum1 = 0; | |
var oldnum2 = 0; | |
var loop_var = setInterval(solver, 100); | |
//clearInterval(loop_var) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment