Created
April 21, 2024 13:52
-
-
Save Tobiaqs/78d289e8d8c483843859f47abf422989 to your computer and use it in GitHub Desktop.
KPN get extra 2GB Puppeteer
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
import puppeteer from 'puppeteer' | |
;(async () => { | |
// Launch the browser and open a new blank page | |
const browser = await puppeteer.launch() | |
const page = await browser.newPage() | |
// Navigate the page to a URL | |
await page.goto('https://mijn.kpn.com/') | |
// Set screen size | |
await page.setViewport({width: 1080, height: 1024}) | |
// Type into search box | |
await page.waitForSelector('#email', { visible: true }) | |
await page.type('#email', '[email protected]') | |
await page.waitForSelector('#password', { visible: true }) | |
await page.type('#password', 'YourPassword@#$') | |
// // Wait and click on first result | |
const loginButton = 'button[type="submit"]' | |
await page.waitForSelector(loginButton, { visible: true }) | |
await page.click(loginButton) | |
await page.waitForFunction("window.location.hash == '#/overzicht'") | |
await page.goto('https://mijn.kpn.com/#/producten/YOUR_PRODUCT_ID') | |
const extraOptions = await page.waitForSelector('text/Extra opties wijzigen of toevoegen', { visible: true }) | |
await extraOptions.click() | |
await page.waitForFunction("window.location.pathname === '/classic/' && window.location.hash === '#/abonnement'") | |
const extraMBs = await page.waitForSelector("text/Extra MB's/min/sms", { visible: true }) | |
await extraMBs.click() | |
const dayBundle = await page.waitForSelector('text/2 GB extra dagbundel', { visible: true }) | |
await dayBundle.click() | |
const agree = await page.waitForSelector('.col-md-4:not(.ng-hide) #agree', { visible: true }) | |
await agree.click() | |
const btn = await page.waitForSelector('text/Zet extra optie aan') | |
await btn.click() | |
await page.waitForSelector('text/Bedankt voor uw bestelling. Het kan een uur duren voordat deze wijziging zichtbaar is in MijnKPN.', { visible: true }) | |
await browser.close() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment