-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyt-tor-vote.js
72 lines (55 loc) · 2.13 KB
/
yt-tor-vote.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
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin());
(async () => {
const args = ['--proxy-server=socks5://127.0.0.1:9050'];
const browser = await puppeteer.launch({
args
})
// let selector = 'input[id="choice-420494d8-dfd9-402b-b535-24fd07f4a78b-selector"]'
const page = await browser.newPage();
await page.goto('https://ytcreatorsfestival.com/poll/ghana-creators-awards-2023/', {timeout: 0, waitUntil: 'domcontentloaded'});
await page.setDefaultNavigationTimeout(0);
await page.setRequestInterception(true).catch(()=> console.log("Did not work"));
page.on('request', (request) => {
if (request.url().endsWith('.png') || request.url().endsWith('.jpg')){
request.abort();
}else{
request.continue()
}
})
// let isNotLoadedAwait = await page.evaluate(()=> {
// let element = document.querySelector('h1').innerHTML
// })
// console.log(isNotLoadedAwait)
let statusCode = 503;
let count = 0
for (let i = 0; i <= 100; i++){
//await page.waitForSelector(selector,{timeout:1000}).catch(()=> console.log("Class not found"))
await enterDetails(page)
await submitButton(page)
await page.waitForTimeout(2000)
await page.reload()
await page.waitForTimeout(1000)
await enterDetails(page)
await submitButton(page)
console.log(count++);
}
await browser.close()
})();
async function enterDetails(page){
await page.evaluate(()=> {
let selector = 'input[id="choice-420494d8-dfd9-402b-b535-24fd07f4a78b-selector"]'
let sweetieBaiden = document.querySelector(selector);
// page.waitForSelector(sweetieBaiden);
sweetieBaiden.click();
})
}
async function submitButton(page){
await page.evaluate(()=> {
let button = document.querySelector('button[value="vote"]') ;
// page.waitForSelector('button[value="vote"]');
button.click();
//page.waitForSelector(button);
})
}