Skip to content

Commit

Permalink
pg: update selectors for internal/external games, fixes #164
Browse files Browse the repository at this point in the history
  • Loading branch information
vogler committed Jul 13, 2023
1 parent 04bd56c commit 2e8a731
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions prime-gaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ 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
await page.waitForTimeout(2000); // TODO networkidle wasn't enough to load all already collected games
const games = page.locator('div[data-a-target="offer-list-FGWP_FULL"]');
await games.waitFor();
console.log('Number of already claimed games (total):', await games.locator('p:has-text("Collected")').count());
// can't use .all() since the list of elements via locator will change after click while we iterate over it
const internal = await games.locator('[data-a-target="claim-prime-offer-card"]:has-text("Claim")').elementHandles();
const external = games.locator('[data-a-target="learn-more-card"]:has(p:text-is("Claim"))'); // using .elementHandles() here would lead to error due to page navigation: elementHandle.$: Protocol error (Page.adoptNode)
const internal = await games.locator('.item-card__action:has([data-a-target="FGWPOffer"])').elementHandles();
const external = games.locator('.item-card__action:has([data-a-target="ExternalOfferClaim"])'); // using .elementHandles() here would lead to error due to page navigation: elementHandle.$: Protocol error (Page.adoptNode)
console.log('Number of free unclaimed games (Prime Gaming):', internal.length);
// claim games in internal store
for (const card of internal) {
Expand Down

0 comments on commit 2e8a731

Please sign in to comment.