From 4ff208a6b0047f4cfebbf77250383ebc31b01644 Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Wed, 3 Aug 2022 00:43:54 +0200 Subject: [PATCH] prime-gaming: screenshots: internal before claim, end-of-run just games instead of full page --- prime-gaming.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/prime-gaming.js b/prime-gaming.js index 0bb4196..4999449 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -75,13 +75,13 @@ try { // const title = await card.locator('h3').first().innerText(); 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(); - db.data.claimed.push({ title, time: datetime(), store: 'internal' }); - run.c_internal++; // const img = await (await card.$('img.tw-image')).getAttribute('src'); // console.log('Image:', img); const p = path.resolve(dirs.screenshots, 'prime-gaming', 'internal', `${sanitizeFilename(title)}.png`); await card.screenshot({ path: p }); + await (await card.$('button:has-text("Claim game")')).click(); + db.data.claimed.push({ title, time: datetime(), store: 'internal' }); + run.c_internal++; // await page.pause(); } // claim games in external/linked stores. Linked: origin.com, epicgames.com; Redeem-key: gog.com, legacygames.com @@ -99,7 +99,7 @@ try { // await page.waitForNavigation(); await Promise.any([page.click('button:has-text("Claim now")'), page.click('button:has-text("Complete Claim")')]); // waits for navigation const store_text = await (await page.$('[data-a-target="hero-header-subtitle"]')).innerText(); - // FULL GAME FOR PC ON: GOG.COM, ORIGIN, LEGACY GAMES, EPIC GAMES + // Full game for PC [and MAC] on: gog.com, Origin, Legacy Games, EPIC GAMES, Battle.net // 3 Full PC Games on Legacy Games const store = store_text.toLowerCase().replace(/.* on /, ''); console.log('External store:', store); @@ -133,7 +133,8 @@ try { await page.click('button[data-type="Game"]'); } while (n); const p = path.resolve(dirs.screenshots, 'prime-gaming', `${datetime()}.png`); - await page.screenshot({ path: p, fullPage: true }); + // await page.screenshot({ path: p, fullPage: true }); + await page.locator(games_sel).screenshot({ path: p }); } catch(error) { console.error(error); run.error = error.toString();