From 60acf747d04f74a9412e93daad4890b9ea04456c Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Wed, 17 May 2023 00:55:58 +0200 Subject: [PATCH] pg: scroll to bottom to load all games There may be so many unclaimed games that not all of them are loaded initially. Also relevant to show the correct number of collected games. --- prime-gaming.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/prime-gaming.js b/prime-gaming.js index 8390fd5..d5d9453 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -93,6 +93,8 @@ try { } await page.click('button[data-type="Game"]'); + await page.keyboard.press('End'); // scroll to bottom to show all games + await page.waitForLoadState('networkidle'); // wait for all games to be loaded const games_sel = 'div[data-a-target="offer-list-FGWP_FULL"]'; await page.waitForSelector(games_sel); console.log('Number of already claimed games (total):', await page.locator(`${games_sel} p:has-text("Collected")`).count()); @@ -102,6 +104,7 @@ try { // for (let i=1; i<=n; i++) { for (const card of games) { // const card = page.locator(`:nth-match(${game_sel}, ${i})`); // this will reevaluate after games are claimed and index will be wrong + await card.scrollIntoViewIfNeeded(); // 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);