Skip to content

Instantly share code, notes, and snippets.

@culy247
Created January 13, 2025 02:29
Show Gist options
  • Save culy247/271055b197739eede66d94d81aade5e5 to your computer and use it in GitHub Desktop.
Save culy247/271055b197739eede66d94d81aade5e5 to your computer and use it in GitHub Desktop.
blum bot auto click
// ==UserScript==
// @name Blum new auto click Game
// @namespace Violentmonkey Scripts
// @match https://telegram.blum.codes/*
// @grant none
// @version 1.0
// @author airdropsangmes
// @description 15:03:27 16/10/2024
// ==/UserScript==
let GAME_SETTINGS = {
clickPercentage: {
bomb: 100,
ice: 100,
flower: Math.floor(Math.random() * (90 - 80 + 1)) + 50,
dogs: Math.floor(Math.random() * (90 - 80 + 1)) + 80,
},
autoClickPlay: false,
};
let isGamePaused = true;
let isSettingsOpen = false;
try {
let gameStats = {
isGameOver: false,
};
const originalPush = Array.prototype.push;
Array.prototype.push = function (...items) {
if (!isGamePaused) {
items.forEach((item) => handleGameElement(item));
}
return originalPush.apply(this, items);
};
async function handleGameElement(element) {
if (!element || !element.asset) return;
const { assetType } = element.asset;
const randomValue = Math.random() * 100;
switch (assetType) {
case "CLOVER":
if (randomValue < GAME_SETTINGS.clickPercentage.flower) {
await clickElementWithDelay(element);
}
break;
case "BOMB":
if (randomValue < GAME_SETTINGS.clickPercentage.bomb) {
await clickElementWithDelay(element);
}
break;
case "FREEZE":
if (randomValue < GAME_SETTINGS.clickPercentage.ice) {
await clickElementWithDelay(element);
}
break;
case "DOGS":
if (randomValue < GAME_SETTINGS.clickPercentage.dogs) {
await clickElementWithDelay(element);
}
break;
default:
console.log(`Unknown element type: ${assetType}`);
}
}
function clickElementWithDelay(element) {
const clickDelay = Math.floor(Math.random() * (1500 - 200 + 1)) + 200;
setTimeout(() => {
element.onClick(element);
element.isExplosion = true;
element.addedAt = performance.now();
}, clickDelay);
}
function checkGameCompletion() {
const rewardElement = document.querySelector(
"#app > div > div > div.content > div.reward"
);
if (rewardElement && !gameStats.isGameOver) {
gameStats.isGameOver = true;
}
}
function getNewGameDelay() {
return Math.floor(Math.random() * (3000 - 1000 + 1)) + 1000;
}
function checkAndClickPlayButton() {
const playButtons = document.querySelectorAll(
'button.kit-button.is-large.is-primary, a.play-btn[href="/game"], button.kit-button.is-large.is-primary'
);
playButtons.forEach((button) => {
if (
!isGamePaused &&
GAME_SETTINGS.autoClickPlay &&
(/Play/.test(button.textContent) || /Continue/.test(button.textContent))
) {
setTimeout(() => {
button.click();
gameStats.isGameOver = false;
}, getNewGameDelay());
} else if (
!isGamePaused &&
GAME_SETTINGS.autoClickPlay &&
(/Chơi/.test(button.textContent) || /Continue/.test(button.textContent))
) {
setTimeout(() => {
button.click();
gameStats.isGameOver = false;
}, getNewGameDelay());
}
});
}
function continuousPlayButtonCheck() {
checkAndClickPlayButton();
setTimeout(continuousPlayButtonCheck, 1000);
}
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (mutation.type === "childList") {
checkGameCompletion();
}
}
});
const appElement = document.querySelector("#app");
if (appElement) {
observer.observe(appElement, {
childList: true,
subtree: true,
});
}
const controlsContainer = document.createElement("div");
controlsContainer.style.position = "fixed";
controlsContainer.style.top = "0";
controlsContainer.style.left = "50%";
controlsContainer.style.transform = "translateX(-50%)";
controlsContainer.style.zIndex = "9999";
controlsContainer.style.backgroundColor = "transparent";
controlsContainer.style.padding = "10px 20px";
controlsContainer.style.borderRadius = "10px";
document.body.appendChild(controlsContainer);
const buttonsContainer = document.createElement("div");
buttonsContainer.style.display = "flex";
buttonsContainer.style.justifyContent = "center";
controlsContainer.appendChild(buttonsContainer);
const pauseButton = document.createElement("button");
pauseButton.textContent = "â–¶";
pauseButton.style.padding = "3px 20px";
pauseButton.style.backgroundColor = "#1d82dc";
pauseButton.style.color = "white";
pauseButton.style.border = "none";
pauseButton.style.borderRadius = "10px";
pauseButton.style.cursor = "pointer";
pauseButton.style.marginRight = "5px";
pauseButton.onclick = () => {
toggleGamePause();
};
buttonsContainer.appendChild(pauseButton);
const settingsButton = document.createElement("button");
settingsButton.textContent = "⛯";
settingsButton.style.padding = "4px 8px";
settingsButton.style.backgroundColor = "#5d2a8f00";
settingsButton.style.color = "white";
settingsButton.style.border = "none";
settingsButton.style.borderRadius = "10px";
settingsButton.style.cursor = "pointer";
settingsButton.onclick = toggleSettings;
buttonsContainer.appendChild(settingsButton);
const settingsContainer = document.createElement("div");
settingsContainer.style.display = "none";
settingsContainer.style.marginTop = "10px";
controlsContainer.appendChild(settingsContainer);
function toggleSettings() {
isSettingsOpen = !isSettingsOpen;
if (isSettingsOpen) {
settingsContainer.style.display = "block";
settingsContainer.innerHTML = "";
const table = document.createElement("table");
table.style.color = "white";
const items = [
{
label: "🍀 Flower %",
settingName: "flower",
},
{
label: "🐶 DOGS %",
settingName: "dogs",
},
];
items.forEach((item) => {
const row = table.insertRow();
const labelCell = row.insertCell();
labelCell.textContent = item.label;
const inputCell = row.insertCell();
const inputElement = document.createElement("input");
inputElement.type = "number";
inputElement.value = GAME_SETTINGS.clickPercentage[item.settingName];
inputElement.min = 0;
inputElement.max = 100;
inputElement.style.width = "50px";
inputElement.addEventListener("input", () => {
GAME_SETTINGS.clickPercentage[item.settingName] = parseInt(
inputElement.value,
10
);
});
inputCell.appendChild(inputElement);
});
settingsContainer.appendChild(table);
} else {
settingsContainer.style.display = "none";
}
}
function toggleGamePause() {
isGamePaused = !isGamePaused;
if (isGamePaused) {
pauseButton.textContent = "â–¶";
GAME_SETTINGS.autoClickPlay = false;
} else {
pauseButton.textContent = "❚❚";
GAME_SETTINGS.autoClickPlay = true;
continuousPlayButtonCheck();
}
}
function play() {
const interval = Math.random(0, 1) * 10000 + 10000;
setTimeout(() => {
const playButton = document.querySelector("button.is-primary, .play-btn");
if (!playButton) return;
if (!playButton.textContent.toLowerCase().includes("play")) return;
playButton.click();
}, interval);
}
(() => {
if (window.BlumAC) return;
window.BlumAC = true;
const autoPlay = true;
if (autoPlay) {
setInterval(() => {
play();
}, 10000);
}
setInterval(() => {
const canvas = document.querySelector("canvas");
if (canvas) clickNearUpperMidHorizontalLine(canvas);
}, 100);
function clickNearUpperMidHorizontalLine(screenCanvas) {
const width = screenCanvas.width;
const height = screenCanvas.height;
const spacing = width / 30; // 30 click points across the width
const adjustment = Math.floor(height * 0.2); // 20% of the height
const adjustedMidY = Math.floor(height * 0.2); // 20% down from the top
for (let i = 0; i < 30; i++) {
const x = Math.floor(i * spacing);
simulateClick(screenCanvas, x, adjustedMidY);
}
}
function simulateClick(canvas, x, y) {
const prop = {
clientX: x,
clientY: y,
bubbles: true,
};
canvas.dispatchEvent(new MouseEvent("click", prop));
canvas.dispatchEvent(new MouseEvent("mousedown", prop));
canvas.dispatchEvent(new MouseEvent("mouseup", prop));
}
})();
} catch (e) {
console.error("!BlumFarm! error:", e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment