-
Notifications
You must be signed in to change notification settings - Fork 73
/
index.js
317 lines (243 loc) · 17.5 KB
/
index.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
const puppeteer = require("puppeteer");
const colors = require('colors/safe');
const logger = require("./logger");
const fs = require('fs');
(async () => {
let i = 0;
const tokens = fs.readFileSync('output/verified.txt', 'utf-8').toString().replace(/\r\n/g,'\n').split('\n');
for ( i; i <= tokens.length; i++) {
const waitForResponse = (page, url) => {
return new Promise(resolve => {
page.on("response", function callback(response){
if (response.url() === url) {
resolve(response);
page.removeListener("response",callback)
}
})
})
};
async function main() {
const tokens = fs.readFileSync('output/verified.txt', 'utf-8').toString().replace(/\r\n/g,'\n').split('\n');
//const pathToExtension = require('path').join(__dirname, 'proxy-extension');
const browser = await puppeteer.launch({
headless: false,
/*args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,
],*/
});
const targets = await browser.targets();
const backgroundPageTarget = targets.find(
(target) => target.type() === 'background_page'
);
const page = await browser.newPage();
page.on('requestfailed', request => {
console.log(`url: ${request.url()}, errText: ${request.failure().errorText}, method: ${request.method()}`)
});
// Catch console log errors
page.on("pageerror", err => {
console.log(`Page error: ${err.toString()}`);
});
await page.setDefaultNavigationTimeout(0);
const pageUrl = 'https://discord.com/login?redirect_to=%2Foauth2%2Fauthorize%3Fscope%3Didentify%2520guilds%2520email%26redirect_uri%3Dhttps%253A%252F%252Ftop.gg%252Flogin%252Fcallback%26response_type%3Dcode%26client_id%3D264434993625956352';
try {
await page.goto(pageUrl, {
timeout: 70000
});
} catch (error) {
await browser.close()
}
// old theme function
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function oldTheme() {
try {
console.log(i)
await page.waitForSelector(".menu.container", {timeout: 0})
console.log('Found old menu')
await page.click('#menu-trigger')
console.log('Click old menu')
await page.click('.menu.container a[href^="/login"]')
console.log('clicked the login btn')
await page.waitForSelector(".marginBottom20-32qID7", {timeout: 70000})
await page.setBypassCSP(true);
await console.log(logger.try(`Trying Logging into the account.`, false))
let tokenTarget = tokens[i]
await page.evaluate(({tokenTarget}) => {
function login(token) {
setInterval(() => {
document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
}, 50);
setTimeout(() => {
location.reload();
}, 2500);
};
login(tokenTarget)
},{tokenTarget});
await page.waitForSelector(".button-38aScr.lookFilled-1Gx00P.colorBrand-3pXr91.sizeMedium-1AC_Sl.grow-q77ONN", {timeout: 70000})
await page.click('.button-38aScr.lookFilled-1Gx00P.colorBrand-3pXr91.sizeMedium-1AC_Sl.grow-q77ONN')
await sleep(10000)
let [unValidToken] = await page.$x(`//div[@class='colorStandard-2KCXvj size16-1P40sf text-23oMQC']`)
if(unValidToken) {
await console.log(logger.err(`This Token isn't Working: ${tokens[i]}`));
} else if (!unValidToken){
await page.waitForSelector(".menu.container", {timeout: 70000})
console.log('Going to probot vote page')
await page.goto("https://top.gg/bot/probot/vote", {
timeout: 0
});
let adBTN = await page.$(`.css-122cpje`); // if old ads
if(!adBTN) {
await console.log(logger.try(`Removeing the ad..`))
await page.waitForXPath(`//*[@id="modal-root"]/div[2]/div/a[2]`); // ads BTN
var noThanks = await page.$x(`//*[@id="modal-root"]/div[2]/div/a[2]`) // ads BTN
await noThanks[0].click()
await console.log(logger.try(`Clicking the vote BTN.`))
await page.waitForXPath(`//*[@id="vote-button-container"]/div/button`) // vote BTN
var voteBTN = await page.$x(`//*[@id="vote-button-container"]/div/button`) // vote BTN
await voteBTN[0].click()
console.log('Clicked old vote BTN')
await setTimeout(async () => {
let [button] = await page.$x("//button[contains(., 'Come back later.')]");
if (button) {
await console.log(logger.info(`Already voted.`))
} else if (!button) {
await console.log(logger.succ(`Voted successfully.`))
}
await browser.close()
}, 2000);
} else if (adBTN){
await console.log(logger.try(`Wait 10 for the ad.`))
await setTimeout(async () => {
await page.waitForXPath(`//*[@id="__next"]/div/div/div[2]/div/div[2]/div/div[1]/main/div[1]/div/div[2]/button`) // vote BTN
var voteBTN = await page.$x(`//*[@id="__next"]/div/div/div[2]/div/div[2]/div/div[1]/main/div[1]/div/div[2]/button`) // vote BTN
await voteBTN[0].click()
console.log('Clicked new vote btn')
await setTimeout(async () => {
let [button] = await page.$x(`//*[@id="__next"]/div/div[2]/div/div/div[2]/div/div[1]/main/div[1]/div/div[1]/div/p[1]`) || await page.$x(`//p[contains(., 'You have voted too many times from this IP.')]`);
if (button) {
await console.log(logger.info(`Already voted.`))
} else if (!button) {
await console.log(logger.succ(`Voted successfully.`))
}
await browser.close()
}, 2000);
}, 10000);
}
}
} catch (error) {
if(page) {
browser.close()
i--
} else if (!page) {
i--
}
}
};
// new theme function
async function newTheme() {
try {
console.log(i + " - " + tokens[i])
//await page.waitForSelector(".marginBottom20-32qID7", {timeout: 70000})
await page.setBypassCSP(true);
await console.log(logger.try(`Trying Logging into the account.`, false))
let tokenTarget = tokens[i]
await page.evaluate(({tokenTarget}) => {
function login(token) {
setInterval(() => {
document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
}, 50);
setTimeout(() => {
location.reload();
}, 2500);
};
login(tokenTarget)
},{tokenTarget});
await page.waitForSelector(".button-f2h6uQ.lookFilled-yCfaCM.colorBrand-I6CyqQ.sizeMedium-2bFIHr.grow-2sR_-F", {timeout: 70000})
//await page.waitForSelector(".button-38aScr.lookFilled-1Gx00P.colorBrand-3pXr91.sizeMedium-1AC_Sl.grow-q77ONN", {timeout: 15000})
await page.click('.button-f2h6uQ.lookFilled-yCfaCM.colorBrand-I6CyqQ.sizeMedium-2bFIHr.grow-2sR_-F', {timeout: 15000})
console.log('go to probot page')
await page.waitForSelector(`.chakra-avatar__initials.css-vn2b1z`);
await page.goto("https://top.gg/bot/probot/vote", {
timeout: 0
});
await page.reload()
let adBTN = await page.$(`.css-122cpje`); // if old ads
if(!adBTN) {
await console.log(logger.try(`Removeing the ad..`))
await page.waitForXPath(`//*[@id="modal-root"]/div[2]/div/a[2]`); // ads BTN
var noThanks = await page.$x(`//*[@id="modal-root"]/div[2]/div/a[2]`) // ads BTN
await noThanks[0].click()
console.log('Click old add btn')
await console.log(logger.try(`Clicking the vote BTN.`))
await page.waitForXPath(`//*[@id="vote-button-container"]/div/button`) // vote BTN
var voteBTN = await page.$x(`//*[@id="vote-button-container"]/div/button`) // vote BTN
await voteBTN[0].click()
console.log('Clicked old vote btn')
await setTimeout(async () => {
let [button] = await page.$x("//button[contains(., 'Come back later.')]");
if (button) {
await console.log(logger.info(`Already voted.`))
} else if (!button) {
await console.log(logger.succ(`Voted successfully.`))
}
await browser.close()
}, 2000);
} else if (adBTN){
await console.log(logger.try(`Wait 10 sec for the ad.`))
await setTimeout(async () => {
await page.waitForXPath(`//*[@id="__next"]/div/div/div[2]/div/div[2]/div/div[1]/main/div[1]/div/div[2]/button`, {timeout: 0}) // vote BTN
var voteBTN = await page.$x(`//*[@id="__next"]/div/div/div[2]/div/div[2]/div/div[1]/main/div[1]/div/div[2]/button`, {timeout: 0}) // vote BTN
await voteBTN[0].click()
console.log('Clicked new vote btn')
}, 10000);
await sleep(11000)
let [banIP] = await page.$x(`//p[contains(., 'You have voted too many times from this IP.')]`),
[button] = await page.$x(`//p[contains(., 'You have already voted for ProBot ✨ in the past 12 hours.')]`);
if(banIP) {
await console.log(logger.info(`This Proxy is banned gonna try another one.`))
await page.waitForSelector(".marginBottom20-32qID7", {timeout: 500})
} else if (!banIP){
await console.log(logger.succ(`Voted successfully.`))
await sleep(3000)
console.log(`LINE 246`)
await browser.close()
}
}
} catch (error) {
if(page) {
console.log(`LINE 255 error`)
browser.close()
i--
} else if (!page) {
i--
}
}
}
setTimeout(() => {
console.log('Checking the site theme')
}, 1000);
try {
let menu = await page.$(`.menu.container`);
if(menu) {
var ipBTN = await page.$x(`/html/body/div[1]/div/div/div/div[2]/div/button[2]`) // changing ip effect;
if(!ipBTN) {
await oldTheme()
} else if (ipBTN) {
await ipBTN[0].click().then(
await oldTheme()
)
}
await oldTheme()
} else {
await newTheme()
}
} catch (error) {
await console.log(i);
await main()
}
};
await main()
}
})();