-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath_battle_telegram.js
More file actions
40 lines (37 loc) · 1.18 KB
/
math_battle_telegram.js
File metadata and controls
40 lines (37 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const wantedScore = 698;
const correctButton = document.getElementById("button_correct");
const wrongButton = document.getElementById("button_wrong");
var currentScore;
var taskX;
var taskY;
var operation;
var result;
function compareOp(){
currentScore = parseInt(document.getElementById("score_value").innerText);
taskX = parseInt(document.getElementById("task_x").innerText);
taskY = parseInt(document.getElementById("task_y").innerText);
operation = document.getElementById("task_op").innerText;
result = parseInt(document.getElementById("task_res").innerText);
if (operation == "×"){
if (taskX * taskY == result){ correctButton.click(); }
else { wrongButton.click(); }
}
else if (operation == "–"){
if (taskX - taskY == result){ correctButton.click(); }
else { wrongButton.click(); }
}
else if (operation == "/"){
if (taskX / taskY == result){ correctButton.click(); }
else { wrongButton.click(); }
}
else {
if (taskX + taskY == result){ correctButton.click(); }
else { wrongButton.click(); }
}
}
let theInterval = setInterval(()=>{
if (currentScore != wantedScore){
compareOp()
}
else { clearInterval(theInterval) }
}, 1000)