diff --git a/epic-games.js b/epic-games.js index 58fb1d6..e6ea28d 100644 --- a/epic-games.js +++ b/epic-games.js @@ -47,6 +47,7 @@ const page = context.pages().length ? context.pages()[0] : await context.newPage // console.debug('userAgent:', await page.evaluate(() => navigator.userAgent)); const notify_games = []; +let user; try { await context.addCookies([{name: 'OptanonAlertBoxClosed', value: new Date(Date.now() - 5*24*60*60*1000).toISOString(), domain: '.epicgames.com', path: '/'}]); // Accept cookies to get rid of banner to save space on screen. Set accept time to 5 days ago. @@ -94,7 +95,7 @@ try { await page.waitForURL(URL_CLAIM); if (!cfg.debug) context.setDefaultTimeout(cfg.timeout); } - const user = await page.locator('#user span').first().innerHTML(); + user = await page.locator('#user span').first().innerHTML(); console.log(`Signed in as ${user}`); db.data[user] ||= {}; @@ -195,7 +196,7 @@ try { } finally { await db.write(); // write out json db if (notify_games.filter(g => g.status != 'existed').length) { // don't notify if all were already claimed - notify(`epic-games:
${html_game_list(notify_games)}`); + notify(`epic-games (${user}):
${html_game_list(notify_games)}`); } } if (cfg.debug) writeFileSync(path.resolve(cfg.dir.browser, 'cookies.json'), JSON.stringify(await context.cookies())); diff --git a/gog.js b/gog.js index 8fff1ce..a879028 100644 --- a/gog.js +++ b/gog.js @@ -27,6 +27,7 @@ const page = context.pages().length ? context.pages()[0] : await context.newPage // console.debug('userAgent:', await page.evaluate(() => navigator.userAgent)); const notify_games = []; +let user; try { await context.addCookies([{name: 'CookieConsent', value: '{stamp:%274oR8MJL+bxVlG6g+kl2we5+suMJ+Tv7I4C5d4k+YY4vrnhCD+P23RQ==%27%2Cnecessary:true%2Cpreferences:true%2Cstatistics:true%2Cmarketing:true%2Cmethod:%27explicit%27%2Cver:1%2Cutc:1672331618201%2Cregion:%27de%27}', domain: 'www.gog.com', path: '/'}]); // to not waste screen space when non-headless @@ -82,7 +83,7 @@ try { await page.waitForSelector('#menuUsername'); if (!cfg.debug) context.setDefaultTimeout(cfg.timeout); } - const user = await page.locator('#menuUsername').first().textContent(); // innerText is uppercase due to styling! + user = await page.locator('#menuUsername').first().textContent(); // innerText is uppercase due to styling! console.log(`Signed in as '${user}'`); db.data[user] ||= {}; @@ -140,7 +141,7 @@ try { } finally { await db.write(); // write out json db if (notify_games.filter(g => g.status != 'existed').length) { // don't notify if all were already claimed - notify(`gog:
${html_game_list(notify_games)}`); + notify(`gog (${user}):
${html_game_list(notify_games)}`); } } await context.close(); diff --git a/prime-gaming.js b/prime-gaming.js index 0233ebb..dddf912 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -30,6 +30,7 @@ const page = context.pages().length ? context.pages()[0] : await context.newPage // console.debug('userAgent:', await page.evaluate(() => navigator.userAgent)); const notify_games = []; +let user; try { await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); // default 'load' takes forever @@ -78,7 +79,7 @@ try { 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(); + user = await page.locator('[data-a-target="user-dropdown-first-name-text"]').first().innerText(); console.log(`Signed in as ${user}`); // await page.click('button[aria-label="User dropdown and more options"]'); // const twitch = await page.locator('[data-a-target="TwitchDisplayName"]').first().innerText(); @@ -241,7 +242,7 @@ try { } finally { await db.write(); // write out json db if (notify_games.length) { // list should only include claimed games - notify(`prime-gaming:
${html_game_list(notify_games)}`); + notify(`prime-gaming (${user}):
${html_game_list(notify_games)}`); } } await context.close();