forked from lafkpages/FreericeHack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interval.js
52 lines (44 loc) · 1.52 KB
/
interval.js
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
41
42
43
44
45
46
47
48
49
50
51
52
// Define the function
// Save it as a property of window to prevent re-defining variables
window.freeRiceHackFunc = function() {
let problem = document.getElementsByClassName("card-title")[0].innerText;
let pr, answer;
// Check the operation and calculate the answer
if (problem.includes('x')) {
pr = problem.split('x').map(n => parseInt(n));
answer = pr[0] * pr[1];
} else if (problem.includes('/')) {
pr = problem.split('/').map(n => parseInt(n));
answer = pr[0] / pr[1];
} else if (problem.includes('+')) {
pr = problem.split('+').map(n => parseInt(n));
answer = pr[0] + pr[1];
} else if (problem.includes('-')) {
pr = problem.split('-').map(n => parseInt(n));
answer = pr[0] - pr[1];
}
let opts = document.getElementsByClassName('card-button');
let a = opts[0];
let b = opts[1];
let c = opts[2];
let d = opts[3];
if (parseInt(a.innerText) == answer) {
a.click();
} else if (parseInt(b.innerText) == answer) {
b.click();
} else if (parseInt(c.innerText) == answer) {
c.click();
} else if (parseInt(d.innerText) == answer) {
d.click();
}
for (let i = 0; i < window.bruh.length; i++) {
clearTimeout(window.bruh[i]);
bruh.shift();
}
bruh.push(setTimeout(window.freeRiceHackFunc, 400));
}
// Define a list to save all the timeouts
// Save it as a property of window to prevent re-defining variables
window.bruh = [];
// Start the hack with an initial timeout, it will recall itself automatically
bruh.push(setTimeout(window.freeRiceHackFunc, 400));