-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rocky-Rabbit-click.user.js
120 lines (105 loc) · 3.63 KB
/
Rocky-Rabbit-click.user.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
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
// ==UserScript==
// @name Rocky Rabbit Click
// @namespace http://www.google.com/
// @version 1.2
// @description Launch Rocky Rabbit on Telegram Web
// @author Reza
// @match *://*.rockyrabbit.io/*
// @grant none
// @icon https://rockyrabbit.io/images/about1.png
// @downloadURL https://github.com/parsian-ai/Rocky-Rabbit/raw/main/Rocky-Rabbit-click.user.js
// @updateURL https://github.com/parsian-ai/Rocky-Rabbit/raw/main/Rocky-Rabbit-click.user.js
// @homepage https://github.com/parsian-ai/Rocky-Rabbit
// ==/UserScript==
console.clear();
console.log("Game started");
const getRandomInteger = (minimum, maximum) => Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
const getRandomPointInCircle = (radius) => {
let coordinateX, coordinateY;
do {
coordinateX = Math.random() * 2 - 1;
coordinateY = Math.random() * 2 - 1;
} while (coordinateX * coordinateY + coordinateY * coordinateY > 1);
return {
x: Math.round(coordinateX * radius),
y: Math.round(coordinateY * radius)
};
};
const dispatchEvent = (element, eventType, properties) => {
const event = new MouseEvent(eventType, properties);
element.dispatchEvent(event);
};
const simulateClick = (element) => {
const rect = element.getBoundingClientRect();
const radius = Math.min(rect.width, rect.height) / 2;
const { x, y } = getRandomPointInCircle(radius);
const clientX = rect.left + radius + x;
const clientY = rect.top + radius + y;
const eventProps = {
bubbles: true,
cancelable: true,
view: window,
clientX,
clientY,
screenX: clientX,
screenY: clientY,
pageX: clientX,
pageY: clientY,
pointerId: 1,
pointerType: "touch",
isPrimary: true,
width: 1,
height: 1,
pressure: 0.5,
button: 0,
buttons: 1
};
dispatchEvent(element, 'pointerdown', eventProps);
dispatchEvent(element, 'mousedown', eventProps);
dispatchEvent(element, 'pointerup', { ...eventProps, pressure: 0 });
dispatchEvent(element, 'mouseup', eventProps);
dispatchEvent(element, 'click', eventProps);
};
const getCurrentEnergy = () => {
const energyDiv = document.querySelector('.font-chivo-mono.text-sm.text-ltr');
if (energyDiv) {
const energySpan = energyDiv.querySelector('span');
if (energySpan) {
const energyValue = energySpan.textContent;
return parseInt(energyValue, 10);
} else {
return null;
}
} else {
return null;
}
};
const autoClick = () => {
const targetElement = document.querySelector('.flex.items-center.justify-center.relative.z-0.cursor-pointer.touch-none');
if (targetElement) {
simulateClick(targetElement);
} else {
//
}
};
const startAutoClicker = () => {
try {
const energyLevel = getCurrentEnergy();
if (energyLevel === null) {
console.log('Energy level not found, retrying...');
setTimeout(startAutoClicker, 1000);
} else if (energyLevel <= 25) {
const pauseDuration = getRandomInteger(30000, 60000);
console.log(`Energy low, pausing ...`);
setTimeout(startAutoClicker, pauseDuration);
} else {
autoClick();
const clickInterval = getRandomInteger(30, 120);
setTimeout(startAutoClicker, clickInterval);
}
} catch (error) {
console.log('Error in autoClicker:', error.message);
setTimeout(startAutoClicker, 1000);
}
};
setTimeout(startAutoClicker, 3000);