Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ecc521
GitHub Repository: ecc521/gimkit-bot
Path: blob/master/bot.js
1615 views
1
2
//Copy and paste this code into the developer console. Close the console.
3
//Press "s" to start the bot
4
//Press "e" to stop the bot.
5
6
//The bot can not purchase powerups. You will want to purchase the snowstorm powerup (if available)
7
//once the bot gets a couple billion dollars. You may also want to purchase deflector, sheild, or other powerups
8
//that protect you against other players.
9
10
//Please note that some themes may break the bot when applied.
11
12
//Be warned that the bot will get questions wrong initially. This happens because the bot needs
13
//to guess to figure out the correct answer.
14
//The bot will currently not work if the view correct answer setting is off. Improvements that handle this are welcomed.
15
16
17
function randint(max) {
18
return Math.floor(Math.random * (max - 1));
19
}
20
21
(function () {
22
window.alert(
23
"This hack is made by ecc251 and is maintained by Forested Studios\nDo s to start the bot and e to stop it."
24
);
25
if (
26
window.confirm(
27
"According to this statement, you accept that we nor ecc521 are to blame if you get banned or punished."
28
)
29
) {
30
// UTIL
31
const localGetEventListeners = getEventListeners; //For some reason, getEventListeners is not available unless we do this.
32
console.log(localGetEventListeners);
33
const sleep = (m) => new Promise((r) => setTimeout(r, m));
34
35
const upgradePrices = {
36
//TODO: Dynamically figure out prices, in case they change.
37
moneyPerQuestion: [
38
undefined,
39
10,
40
100,
41
1e3,
42
1e4,
43
7.5e4,
44
3e5,
45
1e6,
46
1e7,
47
1e8,
48
],
49
streakBonus: [
50
undefined,
51
15,
52
1.5e2,
53
1.5e3,
54
1.5e4,
55
115e3,
56
450e3,
57
15e5,
58
15e6,
59
2e8,
60
],
61
multiplier: [undefined, 50, 300, 2e3, 12e3, 85e3, 7e5, 65e5, 65e6, 1e9],
62
insurance: [undefined, 10, 250, 1e3, 25e3, 1e5, 1e6, 5e6, 25e6, 5e7], // Ignored
63
};
64
65
const transporter = {};
66
transporter.toggleLoc = () => {
67
// If in shop - goes to questions, if in questions goes to shop
68
clickElement(
69
document.querySelector(
70
'div[style="font-weight: 900; cursor: pointer; font-size: 22px;"]'
71
)
72
);
73
};
74
transporter.toShop = () => {
75
clickElement(document.querySelectorAll("svg.MuiSvgIcon-root")[0]);
76
clickElement(
77
document.querySelectorAll(
78
"nav.MuiList-root.MuiList-padding svg.MuiSvgIcon-root"
79
)[1]
80
);
81
};
82
transporter.toQuestion = () => {
83
clickElement(document.querySelectorAll("svg.MuiSvgIcon-root")[0]);
84
clickElement(
85
document.querySelectorAll(
86
"nav.MuiList-root.MuiList-padding svg.MuiSvgIcon-root"
87
)[0]
88
);
89
};
90
transporter.simpleClick = clickElement;
91
console.log("Transporter: loaded");
92
93
function clickElement(elem) {
94
//Mobile event dispatch order
95
let events = [
96
"touchstart",
97
"touchend",
98
"mouseover",
99
"mousemove",
100
"mousedown",
101
"mouseup",
102
"click",
103
];
104
console.log(elem);
105
106
events.forEach((event) => {
107
if (event.includes("mouse") || event == "click") {
108
elem.dispatchEvent(
109
new MouseEvent("click", {
110
bubbles: true,
111
})
112
);
113
}
114
});
115
}
116
console.log("ClickElement: loaded");
117
118
//TODO: Handle view correct answer setting being off.
119
//We will remember what the questions were, and what the correct answer to them was. This will mean, that,
120
//after we have guessed the correct answer to a question, we won't miss it in the future.
121
let results = {};
122
123
function getMoney() {
124
return Number(
125
document
126
.querySelector("body > div > div")
127
.innerText.split(",")
128
.join("")
129
.split("\n")[0]
130
.slice(1)
131
);
132
}
133
console.log("GetMoney: loaded");
134
async function answerQuestion() {
135
transporter.toQuestion();
136
137
// elem[0] is question/header text, 1-4 are answer buttons
138
let elements = document.querySelectorAll("span.notranslate.lang-en");
139
console.log(elements);
140
questionName = elements[0].innerText;
141
index = 1;
142
143
if (results[questionName]) {
144
let answer = results[questionName];
145
146
for (let i = 1; i < elements.length; i++) {
147
if (elements[i].innerText == answer) {
148
index = i;
149
break;
150
}
151
}
152
}
153
console.log("[Async] AnswerQuestion: loaded");
154
155
let guessing = elements[index].innerText;
156
157
localGetEventListeners(document).click[0].listener({
158
isTrusted: true,
159
target: elements[index],
160
type: "click"
161
});
162
163
console.log(elements);
164
console.log(index);
165
console.log(guessing);
166
167
await sleep(450 + randint(50));
168
console.log(
169
document.querySelector(".fade-router-enter-done .animated.jello")
170
);
171
let lost = document
172
.querySelector(".fade-router-enter-done .animated.jello")
173
.innerText.startsWith("-");
174
// One of shop and viewCorrectAnswer exist
175
if (!lost) {
176
// Correct
177
// Save the answer to the question.
178
results[questionName] = guessing;
179
180
let money = getMoney();
181
let shopIndex; //Money per question, streak, multiplier, insurance (not useful).
182
let moneyIndex = upgradePrices.moneyPerQuestion.findIndex((x) => {
183
return money >= x;
184
});
185
let streakIndex = upgradePrices.streakBonus.findIndex((x) => {
186
return money >= x;
187
});
188
let multiplierIndex = upgradePrices.multiplier.findIndex((x) => {
189
return money >= x;
190
});
191
let purchaseIndex;
192
193
if (moneyIndex != -1) {
194
shopIndex = 0;
195
purchaseIndex = moneyIndex;
196
upgradePrices.moneyPerQuestion[moneyIndex] = undefined;
197
} else if (streakIndex != -1) {
198
shopIndex = 1;
199
purchaseIndex = streakIndex;
200
upgradePrices.streakBonus[streakIndex] = undefined;
201
} else if (multiplierIndex != -1) {
202
shopIndex = 2;
203
purchaseIndex = multiplierIndex;
204
upgradePrices.multiplier[multiplierIndex] = undefined;
205
}
206
console.log(money);
207
console.log(shopIndex);
208
console.log(purchaseIndex);
209
console.log(moneyIndex, streakIndex, multiplierIndex);
210
211
if (shopIndex != undefined) {
212
transporter.toShop();
213
//TODO: Add powerups.
214
await sleep(400);
215
216
let options = document.querySelectorAll(
217
"body > div > div > div:nth-child(3) > div:nth-child(1) > div > div > div"
218
);
219
console.log(options);
220
transporter.simpleClick(options[shopIndex]);
221
222
await sleep(400);
223
224
// Indexes 3-12 are purchase options.
225
let selections = document.querySelectorAll(
226
"body > div > div > div:nth-child(3) > div:nth-child(1) > div > div > div > div"
227
);
228
clickElement(selections[purchaseIndex + 3]); // Original attempts I see... for some reason none of these "shop selections work" just checking why - will be fixed
229
// Select the upgrade
230
await sleep(300);
231
transporter.simpleClick(selections[2]); //Buy it.
232
await sleep(300);
233
// document.querySelectorAll("body > div > div > div > div > div")[2].click() //Click to go back to the questions.
234
transporter.toQuestion();
235
} else {
236
// let nextQuestion = document.querySelector("#root > div > div.sc-lkqHmb.fDovdT > div:nth-child(1) > div > div > div.sc-bxivhb.guENId > span:nth-child(2) > div > div > div > div")
237
// transporter.simpleClick(nextQuestion)
238
transporter.toQuestion();
239
}
240
} else {
241
//TODO: View Correct Answer button no longer being clicked. Probably requires the same getEventListeners change.
242
243
//Click "View Correct Answer"
244
let viewCorrectAnswer = document.evaluate(
245
"//div[contains(text(),'View Correct Answer')]",
246
document,
247
null,
248
XPathResult.FIRST_ORDERED_NODE_TYPE,
249
null
250
).singleNodeValue;
251
transporter.simpleClick(viewCorrectAnswer);
252
await sleep(400);
253
//Grab the answer
254
let correctAnswer = document.querySelector(
255
"body > div > div > div:nth-child(3) > div:nth-child(1) > div > div > div > div > div:nth-child(3)"
256
).innerText;
257
//Store the correct answer for later use.
258
results[questionName] = correctAnswer;
259
//transporter.simpleClick(document.querySelector("span>div>div>div>div")) // Clicks the next button thing
260
transporter.toQuestion();
261
}
262
await sleep(400);
263
}
264
let answering = false;
265
266
function stopAnswering() {
267
answering = false;
268
}
269
270
async function startAnswering() {
271
answering = true;
272
while (answering === true) {
273
await answerQuestion();
274
}
275
}
276
277
async function toggleAnswer() {
278
// You can use if wanted
279
answering = !answering;
280
while (answering) {
281
await answerQuestion();
282
}
283
}
284
285
//Allow pressing s to start
286
window.addEventListener("keyup", function (e) {
287
if (e.key == "s") {
288
startAnswering();
289
}
290
});
291
//Allow pressing e to end
292
window.addEventListener("keyup", function (e) {
293
if (e.key == "e") {
294
stopAnswering();
295
}
296
});
297
console.log("Script loaded successfully");
298
} else {
299
}
300
})();
301
302