Created
November 25, 2020 23:02
-
-
Save horosin/8ec8b1b79f4a55fa5fd932a620f93634 to your computer and use it in GitHub Desktop.
Bot for my brother
This file contains hidden or 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 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