-
Notifications
You must be signed in to change notification settings - Fork 0
/
terminal.user.js
150 lines (121 loc) · 5.05 KB
/
terminal.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
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
// ==UserScript==
// @name Terminal claim
// @version 0.11
// @author IvanAgafonov
// @match https://app.0xterminal.game/*
// @grant none
// @downloadURL https://github.com/IvanAgafonov/test-violentmonkey/raw/main/terminal.user.js
// @updateURL https://github.com/IvanAgafonov/test-violentmonkey/raw/main/terminal.user.js
// @homepage https://github.com/IvanAgafonov/test-violentmonkey
// ==/UserScript==
function shuffle(array) {
let currentIndex = array.length;
// While there remain elements to shuffle...
while (currentIndex != 0) {
// Pick a remaining element...
let randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;
// And swap it with the current element.
[array[currentIndex], array[randomIndex]] = [
array[randomIndex], array[currentIndex]];
}
}
function getRandomDelay(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Триггеры событий
function triggerEvents(element) {
const events = [
new MouseEvent('mouseover', {
'view': window,
'bubbles': true,
'cancelable': true
}),
new PointerEvent('pointerdown', { bubbles: true, cancelable: true, isTrusted: true, pointerId: 1, width: 1, height: 1, pressure: 0.5, pointerType: "touch" }),
new MouseEvent('mousedown', { bubbles: true, cancelable: true, isTrusted: true, screenX: 182, screenY: 877 }),
new PointerEvent('pointerup', { bubbles: true, cancelable: true, isTrusted: true, pointerId: 1, width: 1, height: 1, pressure: 0, pointerType: "touch" }),
new MouseEvent('mouseup', { bubbles: true, cancelable: true, isTrusted: true, screenX: 182, screenY: 877 }),
new PointerEvent('click', { bubbles: true, cancelable: true, isTrusted: true, pointerId: 1, width: 1, height: 1, pressure: 0, pointerType: "touch" }),
new PointerEvent('pointerout', { bubbles: true, cancelable: true, isTrusted: true, pointerId: 1, width: 1, height: 1, pressure: 0, pointerType: "touch" }),
new PointerEvent('pointerleave', { bubbles: true, cancelable: true, isTrusted: true, pointerId: 1, width: 1, height: 1, pressure: 0, pointerType: "touch" }),
new MouseEvent('mouseout', { bubbles: true, cancelable: true, isTrusted: true, screenX: 182, screenY: 877 }),
new MouseEvent('mouseleave', { bubbles: true, cancelable: true, isTrusted: true, screenX: 182, screenY: 877 })
];
events.forEach((event, index) => {
setTimeout(() => element.dispatchEvent(event), index * 100);
});
}
function sleep(ms = 0) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function autoBuy() {
var up = Array.from(document.querySelectorAll("button span")).filter(el => el.textContent.includes("Next"));
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("button span")).filter(el => el.textContent.includes("Next"));
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("a span")).filter(el => el.textContent.includes("Got it"));
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("button p")).filter(el => el.textContent == "Continue");
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("button p")).filter(el => el.textContent == "Continue");
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("button p")).filter(el => el.textContent == "Take 1000 $TRMNL & GO!");
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("a span")).filter(el => el.textContent.includes("Collect 1000"));
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("button p")).filter(el => el.textContent == "Got it!");
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("div p")).filter(el => el.textContent == "push");
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("div[class*='size-full rounded-full']"));
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
}
function initializeScript() {
console.log('START terminal claim')
setTimeout(autoBuy, getRandomDelay(8000, 10050));
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeScript);
} else {
initializeScript();
}