-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.user.js
More file actions
427 lines (363 loc) · 15 KB
/
main.user.js
File metadata and controls
427 lines (363 loc) · 15 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
// ==UserScript==
// @name Blum Autoclicker fix
// @version 7.0
// @namespace Violentmonkey Scripts
// @author mudachyo
// @match https://telegram.blum.codes/*
// @grant none
// @icon https://cdn.prod.website-files.com/65b6a1a4a0e2af577bccce96/65ba99c1616e21b24009b86c_blum-256.png
// @downloadURL https://github.com/vsotreshko/bug-free-happiness/raw/main/main.user.js
// @updateURL https://github.com/vsotreshko/bug-free-happiness/raw/main/main.user.js
// ==/UserScript==
const verifyWithCodes = [
{ title: "Crypto Regulations #2", code: "BLUMRULES" },
{ title: "DEX History", code: "GODEX" },
{ title: "What's next for Defi?", code: "BLUMNOW" },
{ title: "What is Slippage?", code: "CRYPTOBUZZ" },
{ title: "Understanding Gas Fees", code: "CRYPTOGAS" },
{ title: "Regulation: Yay or Nay?", code: "BLUMSSS" },
{ title: "Smart Contracts 101", code: "SMARTBLUM" },
{ title: "P2P Trading Safety Tips", code: "BLUMTIPS" },
{ title: "What’s Next for DeFi?", code: "BLUMNOW" },
{ title: "Crypto Slang. Part 3", code: "BOOBLUM" },
{ title: "Crypto Slang. Part 4", code: "LAMBOBLUM" },
{ title: "Blum CMO @ Blockchain Life", code: "BLUMISLIFE" },
{ title: "Dex History #3", code: "LOVEBLUM" },
{ title: "P2P Trading Safety Tips", code: "BLUMTIPS" },
{ title: "Crypto Regulations #2", code: "BLUMRULES" },
{ title: "Future of Telegram. Part 1", code: "TAPBLUM" },
{ title: "Blum COO @ Blockchain Life", code: "LIFEISBLUM" },
{ title: "History of Bitcoin", code: "BIGPIZZA" },
{ title: "Crypto Slang. Part 5", code: "GONNABLUM" },
{ title: "What is Uniswap?", code: "BLUMSHINE" },
{ title: "Crypto in Everyday Life", code: "BLUMANCE" },
{ title: "Memepad Tutorial", code: "MEMEPAD" },
{ title: "Dex Evolution", code: "Blumspark" },
{ title: "Is Binance a DEX?", code: "BLUMIES" },
{ title: "Crypto Communities", code: "BLUMMUNITY" },
{ title: "Dec 20 News", code: "Trump" },
{ title: "Dec 18 News", code: "Mark" },
{ title: "Dec 17 News", code: "Kendrick" },
{ title: "Dec 16 News", code: "BITCOIN" },
{ title: "Dec 13 News", code: "BITCOINJESUS" },
{ title: "Dec 12 News", code: "RIPPLE" },
{ title: "Dec 6 Crypto News", code: "Hundred" },
];
/** Custom functions -------------------------------------------------------------- */
const delay = (ms) => new Promise((res) => setTimeout(res, ms));
const getRandomInt = (min, max) => {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
};
const waitForElement = async (document, selector) => {
console.warn(`Waiting for: ${selector}`);
return new Promise((resolve) => {
if (document.querySelector(selector)) {
console.warn(`waitForElement: found ${selector} immediately`);
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver((mutations) => {
if (document.querySelector(selector)) {
console.warn(`waitForElement: found ${selector} after DOM changed`);
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
// Resolve promise after 10 seconds if element is not found
setTimeout(() => {
console.warn(`waitForElement: ${selector} not found after 10 seconds`);
observer.disconnect();
resolve(null);
}, 10000);
});
};
function executeWithProbability(code, probability = 0.05) {
if (Math.random() < probability) {
code();
}
}
/** ------------------------------------------------------------------------------- */
const playGame = async () => {
(() => {
if (window.BlumAC) return;
window.BlumAC = true;
let gamesCounter = 0;
const config = {
autoPlay: true,
maxGamesInRow: 6,
orangeColor: [226, 122, 52],
greenColor: [208, 216, 0],
whiteColor: [255, 255, 255],
bombColor: [126, 119, 121],
flowerTolerance: 9,
iceTolerance: 9,
bombTolerance: 9,
playButtonSelector: "button.is-primary, .play-btn",
canvasSelector: "canvas",
playCheckInterval: 2500,
objectCheckInterval: 100,
excludedArea: { top: 70, bottom: 50 },
startGameDelay: 1000,
flowerClickProbability: 1,
iceClickProbability: 1,
// Add configuration for surrounding pixel check
surroundingPixelRadius: 1, // Check pixels within this radius
matchThreshold: 0.6, // Percentage of matching surrounding pixels required
};
if (config.autoPlay) {
setInterval(() => {
if (gamesCounter >= config.maxGamesInRow) return;
const playButton = document.querySelector(config.playButtonSelector);
if (playButton && playButton.textContent.toLowerCase().includes("play")) {
playButton.click();
gamesCounter++;
setTimeout(() => {
startAutoClick();
}, config.startGameDelay);
}
}, config.playCheckInterval);
}
function startAutoClick() {
setInterval(() => {
const canvas = document.querySelector(config.canvasSelector);
if (canvas) detectAndClickObjects(canvas);
}, config.objectCheckInterval);
}
// Helper function to check surrounding pixels
function checkSurroundingPixels(pixels, width, height, centerX, centerY, targetColor, tolerance) {
let matchCount = 0;
let totalChecked = 0;
const radius = config.surroundingPixelRadius;
for (let dy = -radius; dy <= radius; dy++) {
for (let dx = -radius; dx <= radius; dx++) {
const x = centerX + dx;
const y = centerY + dy;
// Skip if outside canvas bounds
if (x < 0 || x >= width || y < 0 || y >= height) continue;
const index = (y * width + x) * 4;
const [r, g, b] = [pixels[index], pixels[index + 1], pixels[index + 2]];
totalChecked++;
if (isColorSuits(r, g, b, targetColor, tolerance)) {
matchCount++;
}
}
}
return matchCount / totalChecked >= config.matchThreshold;
}
function detectAndClickObjects(canvas) {
const { width, height } = canvas;
const context = canvas.getContext("2d");
const imageData = context.getImageData(0, 0, width, height);
const pixels = imageData.data;
let loopShouldWork = true;
for (let y = config.excludedArea.top; y < height - config.excludedArea.bottom; y++) {
// if (!loopShouldWork) break;
for (let x = 0; x < width; x++) {
const index = (y * width + x) * 4;
const [r, g, b] = [pixels[index], pixels[index + 1], pixels[index + 2]];
// Check current pixel and surrounding area for each color
if (isColorSuits(r, g, b, config.bombColor, config.bombTolerance)) {
simulateClick(canvas, x, y);
loopShouldWork = false;
break;
}
if (isColorSuits(r, g, b, config.greenColor, config.flowerTolerance)) {
simulateClick(canvas, x, y);
loopShouldWork = false;
break;
}
if (isColorSuits(r, g, b, config.orangeColor, config.flowerTolerance)) {
simulateClick(canvas, x, y);
loopShouldWork = false;
break;
}
if (isColorSuits(r, g, b, config.whiteColor, config.iceTolerance)) {
simulateClick(canvas, x, y);
loopShouldWork = false;
break;
}
}
}
}
function isColorSuits(r, g, b, greenColor, tolerance) {
const gc = greenColor;
const t = tolerance;
const greenRange =
gc[0] - t < r && r < gc[0] + t && gc[1] - t < g && g < gc[1] + t && gc[2] - t < b && b < gc[2] + t;
return greenRange;
}
function simulateClick(canvas, x, y) {
const eventProps = { clientX: x, clientY: y, bubbles: true };
["click", "mousedown", "mouseup"].forEach((event) => {
canvas.dispatchEvent(new MouseEvent(event, eventProps));
});
}
})();
};
const iterateOverTaskItems = async (taskItems, action) => {
if (action === "start" || action === "claim") {
for (const taskItem of taskItems) {
// Find and click the div with text "Start" inside the task item
const startDiv = taskItem.querySelector("div.label");
if (startDiv && startDiv.textContent.trim().toLowerCase() === action) {
startDiv.scrollIntoView();
startDiv.click();
await delay(getRandomInt(2000, 3000)); // Wait for potential action to complete
}
}
}
if (action === "verify") {
for (const taskItem of taskItems) {
const startDiv = taskItem.querySelector("div.label");
if (startDiv && startDiv.textContent.trim().toLowerCase() === "verify") {
console.log(taskItem);
const title = taskItem.querySelector("div.title");
const taskTitle = title?.textContent.trim().toLowerCase();
const verifyWithCode = verifyWithCodes.find(
(code) => code.title.trim().toLowerCase() === taskTitle.trim().toLowerCase()
);
if (verifyWithCode) {
startDiv.scrollIntoView();
startDiv.click();
const verifyPage = await waitForElement(document, "div.pages-tasks-verify");
if (verifyPage) {
const verifyPageTitle = await waitForElement(
verifyPage,
"div.pages-tasks-verify > div.heading > div.title"
);
if (
verifyPage &&
verifyPageTitle.textContent.trim().toLowerCase() === verifyWithCode.title.trim().toLowerCase()
) {
console.log(verifyPageTitle);
const input = await waitForElement(verifyPage, "input[type=text]");
await delay(getRandomInt(1000, 2000));
input.value = verifyWithCode.code;
input.dispatchEvent(new Event("input", { bubbles: true }));
await delay(getRandomInt(1000, 2000));
const submitButton = await waitForElement(verifyPage, "button.kit-button.is-large");
if (submitButton) {
submitButton.click();
await delay(getRandomInt(2000, 3000));
}
}
}
}
}
}
}
};
const claimProof = async (document) => {
const buttonSelector =
"#app > div.tasks-page.page > div.sections > div:nth-child(2) > div.pages-tasks-list.is-short-card > div:nth-child(1) > div > div.footer > button";
const button = await waitForElement(document, buttonSelector);
button.click();
};
const processWeeklyTasks = async (document) => {
const weekly = await waitForElement(
document,
"#app > div.tasks-page.page > div.sections > div:nth-child(2) > div.pages-tasks-list.is-short-card > div > div > div.footer > button"
);
if (weekly) {
weekly.click();
const weeklyPage = await waitForElement(document, "body > div.kit-bottom-sheet > dialog"); // Get all task items
if (weeklyPage) {
const weeklyTaskItems = weeklyPage.querySelectorAll(".pages-tasks-list-item-label"); // Get all task items
await iterateOverTaskItems(weeklyTaskItems, "start"); // Start all
await iterateOverTaskItems(weeklyTaskItems, "verify"); // Verify if needed
await iterateOverTaskItems(weeklyTaskItems, "claim"); // Claim all
}
const closeWeeklyButton = await waitForElement(
document,
"body > div.kit-bottom-sheet > dialog > div.header-with-banner > div > div.right-slot > button"
);
if (closeWeeklyButton) {
closeWeeklyButton.click();
}
}
};
const resolveTasks = async (document) => {
await delay(getRandomInt(3000, 5000)); // Wait page for load
// await claimProof(document);
const tabSelectors = [
"#app > div.tasks-page.page > div.sections > div:nth-child(3) > div > div.kit-tabs-inline.is-fully-left-scrolled > div.content > div > label:nth-child(2)", // New
// "div.tasks-page.page > div.sections > div:nth-child(3) > div > div.kit-tabs > div.content > div > label:nth-child(3) > span", // OnChain
"#app > div.tasks-page.page > div.sections > div:nth-child(3) > div > div.kit-tabs-inline.is-fully-left-scrolled > div.content > div > label:nth-child(4)", // Socials
"#app > div.tasks-page.page > div.sections > div:nth-child(3) > div > div.kit-tabs-inline.is-fully-left-scrolled > div.content > div > label:nth-child(5) > span", // Blum bits
"#app > div.tasks-page.page > div.sections > div:nth-child(3) > div > div.kit-tabs-inline.is-fully-left-scrolled > div.content > div > label:nth-child(6)", // Academy
];
for (const tabSelector of tabSelectors) {
const tab = document.querySelector(tabSelector);
tab.click();
await delay(getRandomInt(1000, 3000)); // Wait page for load
const tasksContainerSelector =
"#app > div.tasks-page.page > div.sections > div:nth-child(3) > div > div.tasks-list";
const tasksContainer = await waitForElement(document, tasksContainerSelector);
const taskItems = tasksContainer.querySelectorAll(".pages-tasks-item"); // Get all task items
await iterateOverTaskItems(taskItems, "start"); // Start all
await iterateOverTaskItems(taskItems, "verify"); // Verify if needed
await iterateOverTaskItems(taskItems, "claim"); // Claim all
}
};
const openTab = async (tabName) => {
const homeTabSelector = "#app > div.layout-tabs.tabs > a:nth-child(1)";
const earnTabSelector = "#app > div.layout-tabs.tabs > a:nth-child(2)";
const frensTabSelector = 'a[href*="/frens"]';
let tab = undefined;
switch (tabName) {
case "home":
tab = await waitForElement(document, homeTabSelector);
break;
case "earn":
tab = await waitForElement(document, earnTabSelector);
break;
case "frens":
tab = await waitForElement(document, frensTabSelector);
break;
}
if (tab) {
tab.click();
}
};
const init = async () => {
// Find "Continue" button
const continueButton = await waitForElement(document, "button.kit-button.is-large.is-fill", 3000);
if (continueButton) {
await delay(2000);
continueButton.click();
}
await openTab("home");
await delay(getRandomInt(1000, 3000));
const dayClaimSelector =
"#app > div.index-page.page > div > div.profile-with-balance > div.pages-index-widgets.widgets > div.pages-index-widgets-daily-reward.widget > div > button";
const dayClaim = await waitForElement(document, dayClaimSelector, 2000);
if (dayClaim) {
await delay(getRandomInt(3000, 5000));
dayClaim.click();
}
await openTab("earn");
await delay(getRandomInt(1000, 3000));
await resolveTasks(document);
await openTab("frens");
await delay(getRandomInt(1000, 3000));
// Claim frens
const frensClaim = await waitForElement(document, "button.claim-button", 2000);
if (frensClaim) {
await delay(getRandomInt(3000, 5000));
frensClaim.click();
}
await openTab("home");
await delay(getRandomInt(1000, 3000));
const startFarming = await waitForElement(document, "button.kit-button.is-large.is-fill.button");
if (startFarming) {
startFarming.click();
}
// playGame();
};
init();
/** ------------------------------------------------------------------------------- */