From b9e9abe546e77ce56443d198c9a4f1be29ae118c Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Sat, 4 Feb 2023 21:37:04 +0100 Subject: [PATCH] page.waitForNavigation -> page.waitForURL --- epic-games.js | 4 ++-- gog.js | 1 - prime-gaming.js | 9 ++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/epic-games.js b/epic-games.js index 704bfd1..e08bf68 100644 --- a/epic-games.js +++ b/epic-games.js @@ -83,7 +83,7 @@ try { notify('epic-games: got captcha during login. Please check.'); }).catch(_ => { }); // handle MFA, but don't await it - page.waitForNavigation({ url: '**/id/login/mfa**'}).then(async () => { + page.waitForURL('**/id/login/mfa**').then(async () => { console.log('Enter the security code to continue - This appears to be a new device, browser or location. A security code has been sent to your email address at ...'); // TODO locator for text (email or app?) const otp = cfg.eg_otpkey && authenticator.generate(cfg.eg_otpkey) || await prompt({type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!'}); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them @@ -94,7 +94,7 @@ try { console.log('Waiting for you to login in the browser.'); notify('epic-games: no longer signed in and not enough options set for automatic login.'); } - await page.waitForNavigation({ url: URL_CLAIM }); + await page.waitForURL(URL_CLAIM); context.setDefaultTimeout(cfg.timeout); } const user = await page.locator('#user span').first().innerHTML(); diff --git a/gog.js b/gog.js index feef173..02dc68f 100644 --- a/gog.js +++ b/gog.js @@ -76,7 +76,6 @@ try { process.exit(1); } } - // await page.waitForNavigation(); // TODO was blocking context.setDefaultTimeout(cfg.timeout); } const user = await page.locator('#menuUsername').first().textContent(); // innerText is uppercase due to styling! diff --git a/prime-gaming.js b/prime-gaming.js index d4e52ab..c340014 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -56,7 +56,7 @@ try { await page.fill('[name=password]', password); await page.check('[name=rememberMe]'); await page.click('input[type="submit"]'); - page.waitForNavigation({ url: '**/ap/signin**'}).then(async () => { // check for wrong credentials + page.waitForURL('**/ap/signin**').then(async () => { // check for wrong credentials const error = await page.locator('.a-alert-content').first().innerText(); console.error(error); notify(`prime-gaming: login: ${error}`); @@ -64,7 +64,7 @@ try { process.exit(1); }); // handle MFA, but don't await it - page.waitForNavigation({ url: '**/ap/mfa**'}).then(async () => { + page.waitForURL('**/ap/mfa**').then(async () => { console.log('Two-Step Verification - enter the One Time Password (OTP), e.g. generated by your Authenticator App'); await page.check('[name=rememberDevice]'); const otp = cfg.pg_otpkey && authenticator.generate(cfg.pg_otpkey) || await prompt({type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!'}); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them @@ -80,7 +80,7 @@ try { process.exit(1); } } - await page.waitForNavigation({ url: 'https://gaming.amazon.com/home?signedIn=true' }); + await page.waitForURL('https://gaming.amazon.com/home?signedIn=true'); if (!cfg.debug) context.setDefaultTimeout(cfg.timeout); } const user = await page.locator('[data-a-target="user-dropdown-first-name-text"]').first().innerText(); @@ -125,8 +125,7 @@ try { const title = await (await card.$('.item-card-details__body__primary')).innerText(); console.log('Current free game:', title); if (cfg.dryrun) continue; - await (await card.$('text=Claim')).click(); - // await page.waitForNavigation(); + await (await card.$('text=Claim')).click(); // goes to URL of game, no need to wait await Promise.any([page.click('button:has-text("Claim now")'), page.click('button:has-text("Complete Claim")'), page.waitForSelector('div:has-text("Link game account")')]); // waits for navigation const store_text = await (await page.$('[data-a-target="hero-header-subtitle"]')).innerText(); // Full game for PC [and MAC] on: gog.com, Origin, Legacy Games, EPIC GAMES, Battle.net