-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgemz-autoclicker.user.js
More file actions
171 lines (152 loc) · 5.64 KB
/
gemz-autoclicker.user.js
File metadata and controls
171 lines (152 loc) · 5.64 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
// ==UserScript==
// @name Gemz Autoclicker
// @version 1.0
// @author mudachyo
// @match *://ff.notgemz.gemz.fun/*
// @icon https://ff.notgemz.gemz.fun/favicon.ico
// @run-at document-start
// @grant none
// @downloadURL https://github.com/mudachyo/Gemz/raw/main/gemz-autoclicker.user.js
// @updateURL https://github.com/mudachyo/Gemz/raw/main/gemz-autoclicker.user.js
// @homepage https://github.com/mudachyo/Gemz
// ==/UserScript==
// Стили логов
const styles = {
success: 'background: #28a745; color: #fff; font-weight: bold; padding: 4px 8px; border-radius: 4px;',
starting: 'background: #8640ff; color: #fff; font-weight: bold; padding: 4px 8px; border-radius: 4px;',
error: 'background: #dc3545; color: #fff; font-weight: bold; padding: 4px 8px; border-radius: 4px;',
info: 'background: #007bff; color: #fff; font-weight: bold; padding: 4px 8px; border-radius: 4px;'
};
const logPrefix = '%c[GemzBot] ';
const originalLog = console.log;
console.log = function () {
if (typeof arguments[0] === 'string' && arguments[0].includes('[GemzBot]')) {
originalLog.apply(console, arguments);
}
};
console.error = console.warn = console.info = console.debug = () => {};
console.clear();
console.log(`${logPrefix}Starting`, styles.starting);
console.log(`${logPrefix}Created by https://t.me/mudachyo`, styles.starting);
console.log(`${logPrefix}Github https://github.com/mudachyo/Gemz`, styles.starting);
// Функция для генерации случайного числа в диапазоне
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Координаты клика
const screenX = 531;
const screenY = 607;
// Функция для создания и отправки событий клика
function clickElement(element) {
const clientX = getRandomInt(0, 485);
const clientY = getRandomInt(0, 242);
const pointerdownEvent = new PointerEvent('pointerdown', {
bubbles: true,
clientX: clientX,
clientY: clientY,
screenX: screenX,
screenY: screenY,
pointerId: 1,
width: 1,
height: 1,
pressure: 0.5
});
const mousedownEvent = new MouseEvent('mousedown', {
bubbles: true,
clientX: clientX,
clientY: clientY,
screenX: screenX,
screenY: screenY
});
const touchstartEvent = new TouchEvent('touchstart', {
bubbles: true,
touches: [new Touch({
identifier: 1,
target: element,
clientX: clientX,
clientY: clientY
})]
});
const pointerupEvent = new PointerEvent('pointerup', {
bubbles: true,
clientX: clientX,
clientY: clientY,
screenX: screenX,
screenY: screenY,
pointerId: 1,
width: 1,
height: 1,
pressure: 0
});
const mouseupEvent = new MouseEvent('mouseup', {
bubbles: true,
clientX: clientX,
clientY: clientY,
screenX: screenX,
screenY: screenY
});
const touchendEvent = new TouchEvent('touchend', {
bubbles: true,
changedTouches: [new Touch({
identifier: 1,
target: element,
clientX: clientX,
clientY: clientY
})]
});
const clickEvent = new PointerEvent('click', {
bubbles: true,
clientX: clientX,
clientY: clientY,
screenX: screenX,
screenY: screenY,
pointerId: 1,
width: 1,
height: 1,
pressure: 0
});
element.dispatchEvent(pointerdownEvent);
element.dispatchEvent(mousedownEvent);
element.dispatchEvent(touchstartEvent);
element.dispatchEvent(pointerupEvent);
element.dispatchEvent(mouseupEvent);
element.dispatchEvent(touchendEvent);
element.dispatchEvent(clickEvent);
}
// Функция для получения текущего уровня энергии
function getEnergyLevel() {
const energyElement = document.querySelector('.progress-info-label .p-2');
return energyElement ? parseInt(energyElement.textContent, 10) : null;
}
// Основная функция для поиска элемента и выполнения кликов
function autoClicker() {
const element = document.querySelector('.hitbox');
if (element) {
clickElement(element);
} else {
console.log(`${logPrefix}Element not found`, styles.error);
}
}
// Функция для выполнения автокликера с проверкой энергии
function runAutoClicker() {
try {
const energyLevel = getEnergyLevel();
if (energyLevel === null) {
console.log(`${logPrefix}Energy level not found, retrying...`, styles.error);
setTimeout(runAutoClicker, 1000);
} else if (energyLevel <= 25) {
const pauseTime = getRandomInt(30000, 60000);
console.log(`${logPrefix}Energy low (${energyLevel}), pausing for ${pauseTime} ms`, styles.info);
setTimeout(runAutoClicker, pauseTime);
} else {
autoClicker();
const intervalTime = getRandomInt(30, 120);
setTimeout(runAutoClicker, intervalTime);
}
} catch (error) {
console.log(`${logPrefix}Error in autoClicker: ${error.message}`, styles.error);
setTimeout(runAutoClicker, 1000); // Пауза на случай ошибки, чтобы продолжить работу
}
}
// Задержка перед первым запуском для полной загрузки страницы
setTimeout(runAutoClicker, 3000);