-
Notifications
You must be signed in to change notification settings - Fork 0
/
skate.user.js
136 lines (110 loc) · 4.6 KB
/
skate.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
// ==UserScript==
// @name Skate claim
// @version 0.1
// @author IvanAgafonov
// @match https://mini-app.skatechain.org/*
// @grant none
// @downloadURL https://github.com/IvanAgafonov/test-violentmonkey/raw/main/skate.user.js
// @updateURL https://github.com/IvanAgafonov/test-violentmonkey/raw/main/skate.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[type='button']")).filter(el => el.textContent.includes("Continue"));
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(4000, 5000));
}
up = Array.from(document.querySelectorAll("button[type='button']")).filter(el => el.textContent.includes("Come back in"));
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("div div div")).filter(el => el.textContent == "Quests");
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("div div button")).filter(el => el.textContent == "Start");
if (up.length != 0){
for (const item of up) {
triggerEvents(item);
// item.click();
await sleep(getRandomDelay(1000, 2000));
}
}
await sleep(getRandomDelay(23000, 25000));
up = Array.from(document.querySelectorAll("div div button")).filter(el => el.textContent == "Partner Quests");
if (up.length != 0){
triggerEvents(up[0]);
// up[0].click();
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("div div button")).filter(el => el.textContent == "Start");
if (up.length != 0){
for (const item of up) {
triggerEvents(item);
// item.click();
await sleep(getRandomDelay(1000, 2000));
}
}
up = Array.from(document.querySelectorAll("div div button")).filter(el => el.textContent == "Connect");
if (up.length != 0){
for (const item of up) {
triggerEvents(item);
// item.click();
await sleep(getRandomDelay(1000, 2000));
}
}
}
function initializeScript() {
console.log('START skate claim')
setTimeout(autoBuy, getRandomDelay(25000, 28050));
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeScript);
} else {
initializeScript();
}