Skip to content

Instantly share code, notes, and snippets.

@IAMOTZ
Created November 3, 2021 22:40
Show Gist options
  • Save IAMOTZ/078e3a7a14d2a2b02f7589abb6461468 to your computer and use it in GitHub Desktop.
Save IAMOTZ/078e3a7a14d2a2b02f7589abb6461468 to your computer and use it in GitHub Desktop.
Web Automation Script To Endlessly Vote Wizkid at EMA 2021 Awards
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