-
Notifications
You must be signed in to change notification settings - Fork 10
/
spacebar.js
54 lines (45 loc) · 1.99 KB
/
spacebar.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
53
54
// _______ ____ _ ____ __
// / _____/ ___ / __ \(_)_______ / __ )____ / /_
// / /__ / __/ / /_/ / / ___/ _ \ / __ / __ \/ __/
// / ___/ / / / _, _/ / /__/ __/ / /_/ / /_/ / /_
// /_/ /_/ /_/ |_/_/\___/\___/ /_____/\____/\__/
//
// Original by: Neil Master/Yeehawlerz101
// Remixed by: LuisAFK
// Notes: Make sure to leave your ad blocker off so that 'freerice' can have some sort of income :)
// How to use: Make an account, sign in, then go to the multiplacation table category (freerice.com/categories/multiplication-table)
// Then when the page loads, go to the console of your web browser and paste this code in the console and enjoy!
// Press the space bar to complete the answer
// https://github.com/lafkpages/FreericeHack
window.freeRiceHackFunc = function(e)
{
if (e.which !== 32)
{
return;
}
let problem = document.getElementsByClassName("card-title")[0].innerText; // '11 x 12'
let pr = problem.replace('x', '*'); // '11 * 12'
let answer = eval(pr); // 132
let opts = document.getElementsByClassName('card-button'); // [HTMLElement, HTMLElement, HTMLElement, HTMLElement]
let a = opts[0]; // HTMLElement
let b = opts[1]; // HTMLElement
let c = opts[2]; // HTMLElement
let d = opts[3]; // HTMLElement
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();
}
}
document.addEventListener('keydown', window.freeRiceHackFunc);