-
Notifications
You must be signed in to change notification settings - Fork 0
/
galactica.user.js
118 lines (94 loc) · 4.25 KB
/
galactica.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
// ==UserScript==
// @name Galactica node sale claim
// @version 0.1
// @author IvanAgafonov
// @match https://nodesale-app.galactica.com/*
// @grant none
// @downloadURL https://github.com/IvanAgafonov/test-violentmonkey/raw/main/galactica.user.js
// @updateURL https://github.com/IvanAgafonov/test-violentmonkey/raw/main/galactica.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 connectWallet(){
var up2 = Array.from(document.querySelectorAll("button div div")).filter(el => el.textContent.includes("Wallet On"))
if (up2.length != 0){
triggerEvents(up2[0]);
await sleep(getRandomDelay(3000, 4100));
up2 = Array.from(document.querySelectorAll("div div button")).filter(el => el.textContent.includes("Open Wallet in Telegram"))
if (up2.length != 0){
triggerEvents(up2[0]);
await sleep(getRandomDelay(20000, 21000));
}
}
}
async function autoBuy() {
var up = Array.from(document.querySelectorAll("div[class='text-[12px] text-[#E0DBD7]']"));
if (up.length != 0){
triggerEvents(up[0]);
await sleep(getRandomDelay(4000, 5000));
}
up = Array.from(document.querySelectorAll("button[type='button']"));
if (up.length != 0){
triggerEvents(up[0]);
await sleep(getRandomDelay(3000, 4000));
}
up = Array.from(document.querySelectorAll("body > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(3) > div:nth-child(2) > svg:nth-child(2)"));
if (up.length != 0){
triggerEvents(up[0]);
await sleep(getRandomDelay(6000, 7000));
}
up = Array.from(document.querySelectorAll("button[type='button']"));
if (up.length != 0){
triggerEvents(up[0]);
await sleep(getRandomDelay(3000, 4000));
}
await connectWallet();
}
function initializeScript() {
console.log('START Galactica claim')
setTimeout(autoBuy, getRandomDelay(10000, 13050));
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeScript);
} else {
initializeScript();
}