-
Notifications
You must be signed in to change notification settings - Fork 0
/
lostdogs.user.js
185 lines (152 loc) · 6.96 KB
/
lostdogs.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// ==UserScript==
// @name LostDogs claim
// @version 0.11
// @author IvanAgafonov
// @match https://dog-ways.newcoolproject.io/*
// @downloadURL https://github.com/IvanAgafonov/test-violentmonkey/raw/main/lostdogs.user.js
// @updateURL https://github.com/IvanAgafonov/test-violentmonkey/raw/main/lostdogs.user.js
// @homepage https://github.com/IvanAgafonov/test-violentmonkey
// @grant none
// ==/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]];
}
}
async function connectWallet(){
var up2 = Array.from(document.querySelectorAll("div")).filter(el => el.textContent == "Wallet On")
if (up2.length != 0){
triggerEvents(up2[0]);
await sleep(getRandomDelay(3000, 4100));
up2 = Array.from(document.querySelectorAll("button")).filter(el => el.textContent.includes("Open Wallet in Telegram"))
if (up2.length != 0){
triggerEvents(up2[0]);
await sleep(getRandomDelay(20000, 21000));
}
}
}
function triggerEvents(element) {
const events = [
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 getRandomDelay(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function sleep(ms = 0) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function simulateTyping(element, text, delay) {
for (const char of text) {
const event = new KeyboardEvent('keydown', { key: char });
element.dispatchEvent(event);
await new Promise(resolve => setTimeout(resolve, delay));
}
for (const char of text) {
const event = new KeyboardEvent('keypress', { key: char });
element.dispatchEvent(event);
await new Promise(resolve => setTimeout(resolve, delay));
}
for (const char of text) {
const event = new KeyboardEvent('keyup', { key: char });
element.dispatchEvent(event);
await new Promise(resolve => setTimeout(resolve, delay));
}
}
async function autoBuy() {
var button = document.evaluate("(//div[text()='Profile'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (button) {
triggerEvents(button);
await sleep(getRandomDelay(3200, 4000));
}
button = document.evaluate("(//div[text()='Connect'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (button) {
triggerEvents(button);
await sleep(getRandomDelay(3200, 4000));
}
await connectWallet();
// var button = document.evaluate("(//div[text()='Confirm'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// triggerEvents(button);
// await sleep(getRandomDelay(3200, 4000));
// }
// button = document.evaluate("(//div[text()='Continue'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// triggerEvents(button);
// await sleep(getRandomDelay(3200, 4000));
// }
// button = document.evaluate("(//div[text()='Continue'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// triggerEvents(button);
// await sleep(getRandomDelay(3200, 4000));
// }
// button = document.evaluate("(//div[text()='Make choice'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// button.click();
// await sleep(getRandomDelay(3200, 4000));
// }
// button = document.evaluate("(//input[@type='range'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// const lastValue = button.value;
// button.value = 0;
// const event = new Event("input", { bubbles: true });
// const tracker = button._valueTracker;
// if (tracker) {
// tracker.setValue(lastValue);
// }
// button.dispatchEvent(event);
// await sleep(getRandomDelay(3200, 4000));
// }
// button = document.evaluate("(//div[text()='Bid 0 $NOT'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// triggerEvents(button);
// await sleep(getRandomDelay(3200, 4000));
// }
// button = document.evaluate("(//div[text()='Share a story'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// triggerEvents(button);
// await sleep(getRandomDelay(3200, 4000));
// }
// button = document.evaluate("(//div[text()='Continue'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// triggerEvents(button);
// await sleep(getRandomDelay(3200, 4000));
// }
// button = document.evaluate("(//div[text()='Continue'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// triggerEvents(button);
// await sleep(getRandomDelay(3200, 4000));
// }
// button = document.evaluate("(//div[text()='What lost dog are you?'])[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
// if (button) {
// triggerEvents(button);
// await sleep(getRandomDelay(3200, 4000));
// }
}
function initializeScript() {
console.log('START LostDogs claim')
setTimeout(autoBuy, getRandomDelay(11000, 13500));
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initializeScript);
} else {
initializeScript();
}