Skip to content

Instantly share code, notes, and snippets.

@jack828
Created September 14, 2022 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jack828/4bc3c2296a478f3c771ec7f40add4457 to your computer and use it in GitHub Desktop.
Save jack828/4bc3c2296a478f3c771ec7f40add4457 to your computer and use it in GitHub Desktop.
HM Hospitales WiFi Auto Submit
#!/usr/bin/env node
const puppeteer = require('puppeteer')
;(async () => {
const browser = await puppeteer.launch({
headless: false,
args: ['--ignore-certificate-errors', '--disable-web-security']
})
const page = await browser.newPage()
await page.goto(`http://example.com/?${Date.now()}`, {
waitUntil: ['domcontentloaded', 'networkidle0']
})
await page.waitForSelector('input[type=email]')
console.log('Portal loaded')
await page.type('input[type=email]', 'ajsdio@disji.com')
await page.evaluate(() => {
document.querySelector('input[type=checkbox]').click()
})
await page.click('input[type=submit]')
await page.waitForNavigation({ waitUntil: 'networkidle0' })
console.log('Got code page')
await page.click('input[type=submit]')
await page.waitForNavigation({ waitUntil: 'networkidle0' })
await page.waitForSelector('#proceed-button')
console.log('Submitted form')
await page.click('#proceed-button')
await page.waitForNavigation({ waitUntil: 'networkidle0' })
console.log('done')
await page.close()
await browser.close()
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment