Created
November 3, 2021 22:40
-
-
Save IAMOTZ/078e3a7a14d2a2b02f7589abb6461468 to your computer and use it in GitHub Desktop.
Web Automation Script To Endlessly Vote Wizkid at EMA 2021 Awards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const vote = async () => { | |
let browser = null; | |
try { | |
const voteUrl = 'https://www.mtvema.com/en-africa/vote/'; | |
browser = await puppeteer.launch({ headless: true }); | |
let page = await browser.newPage(); | |
await page.goto(voteUrl, { waitUntil: 'networkidle0', timeout: 0 }); | |
await page.waitForTimeout(2000); | |
let voteBtns = []; | |
voteBtns = await page.$x("//button[contains(., 'Vote')]"); | |
if (!voteBtns || !voteBtns.length) { | |
voteBtns = await page.$x("//button[contains(., 'Vote Again')]"); | |
} | |
const bigWiz = voteBtns[4]; | |
if (!bigWiz) throw new Error('Can\'t find Big Wiz nomination... something is wrong'); | |
for (let i = 1; i !== 0; i++) { | |
console.count('VOTING') | |
await bigWiz.click(); | |
// Wait for the thank you modal to close | |
await page.waitForTimeout(12000); | |
} | |
} finally { | |
if (browser) { | |
await browser.close(); | |
} | |
} | |
}; | |
vote(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment