From 584c80e93937f1210e9fe922215a7f77bba054b3 Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Thu, 30 Jun 2022 16:43:22 +0200 Subject: [PATCH] screenshots/{prime-gaming/{internal,external}, epic-games} --- epic-games.js | 2 +- prime-gaming.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/epic-games.js b/epic-games.js index a6a406f..ac93d59 100644 --- a/epic-games.js +++ b/epic-games.js @@ -93,7 +93,7 @@ for (let i = 1; i <= n; i++) { console.log('Claimed successfully!'); } catch (e) { console.log(e); - const p = path.resolve(dirs.screenshots, `${new Date().toISOString()}.png`); + const p = path.resolve(dirs.screenshots, 'epic-games', `${new Date().toISOString()}.png`); await page.screenshot({ path: p, fullPage: true }); console.info('Saved a screenshot of hcaptcha challenge to', p); console.error('Got hcaptcha challenge. To avoid it, get a link from https://www.hcaptcha.com/accessibility'); // TODO save this link in config and visit it daily to set accessibility cookie to avoid captcha challenge? diff --git a/prime-gaming.js b/prime-gaming.js index 993e310..92fc676 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -64,6 +64,10 @@ for (const card of games) { const title = await (await card.$('.item-card-details__body__primary')).innerText(); console.log('Current free game:', title); await (await card.$('button:has-text("Claim game")')).click(); + // const img = await (await card.$('img.tw-image')).getAttribute('src'); + // console.log('Image:', img); + const p = path.resolve(dirs.screenshots, 'prime-gaming', 'internal', `${title.replace(/[^a-z0-9]/gi, '_')}.png`); + await card.screenshot({ path: p }); // await page.pause(); } // claim games in linked stores. Origin: key, Epic Games Store: linked @@ -84,7 +88,7 @@ for (const card of games) { const store = store_text.toLowerCase().replace('full game for pc on ', ''); console.log('External store:', store); // save screenshot of potential code just in case - const p = path.resolve(dirs.screenshots, `${title.replace(/[^a-z0-9]/gi, '_')}.png`); + const p = path.resolve(dirs.screenshots, 'prime-gaming', 'external', `${title.replace(/[^a-z0-9]/gi, '_')}.png`); await page.screenshot({ path: p, fullPage: true }); console.info('Saved a screenshot of page to', p); // print code if external store is not connected @@ -102,5 +106,7 @@ for (const card of games) { await page.goto(URL_CLAIM, {waitUntil: 'domcontentloaded'}); await page.click('button[data-type="Game"]'); } while (n); + const p = path.resolve(dirs.screenshots, 'prime-gaming', `${new Date().toISOString()}.png`); + await page.screenshot({ path: p, fullPage: true }); } await context.close();