Skip to content

Instantly share code, notes, and snippets.

@horosin
Created November 25, 2020 23:02
Show Gist options
  • Save horosin/8ec8b1b79f4a55fa5fd932a620f93634 to your computer and use it in GitHub Desktop.
Save horosin/8ec8b1b79f4a55fa5fd932a620f93634 to your computer and use it in GitHub Desktop.
Bot for my brother
const puppeteer = require('puppeteer');
const url = process.argv[2];
if (!url) {
throw "Please provide URL as a first argument";
}
async function run () {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto(url);
const buttonid = "bdalej";
const selector = "#" + buttonid;
while(true) {
await page.waitForFunction(
`!document.getElementById("${buttonid}").classList.contains("disabled")`,
{ timeout: 0 }
);
await Promise.all([
page.waitForNavigation(),
page.click(selector),
]);
}
browser.close();
}
run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment