prime-gaming: clearer log of number of (un)claimed games

This commit is contained in:
Ralf Vogler 2022-02-02 13:53:34 +01:00
parent 1628b16aea
commit 2e08c41933

View file

@ -71,11 +71,11 @@ const TIMEOUT = 20 * 1000; // 20s, default is 30s
if (!debug) context.setDefaultTimeout(TIMEOUT); if (!debug) context.setDefaultTimeout(TIMEOUT);
} }
console.log('Signed in.'); console.log('Signed in.');
const game_sel = 'div[data-a-target="offer-list-FGWP_FULL"] .offer__action:has-text("Claim game")';
await page.waitForSelector('div[data-a-target="offer-list-FGWP_FULL"]'); await page.waitForSelector('div[data-a-target="offer-list-FGWP_FULL"]');
console.log('Number of already claimed games (total):', await page.locator('div[data-a-target="offer-list-FGWP_FULL"] p:has-text("Claimed")').count());
const game_sel = 'div[data-a-target="offer-list-FGWP_FULL"] .offer__action:has-text("Claim game")';
const n = await page.locator(game_sel).count(); const n = await page.locator(game_sel).count();
console.log('Number of free unclaimed games:', n); console.log('Number of free unclaimed games (Prime Gaming):', n);
console.log('Number of already claimed games:', await page.locator('div[data-a-target="offer-list-FGWP_FULL"] p:has-text("Claimed")').count());
const games = await page.$$(game_sel); const games = await page.$$(game_sel);
// for (let i=1; i<=n; i++) { // for (let i=1; i<=n; i++) {
for (const card of games) { for (const card of games) {
@ -91,7 +91,7 @@ const TIMEOUT = 20 * 1000; // 20s, default is 30s
const game_sel = 'div[data-a-target="offer-list-FGWP_FULL"] .offer__action:has(p:text-is("Claim"))'; const game_sel = 'div[data-a-target="offer-list-FGWP_FULL"] .offer__action:has(p:text-is("Claim"))';
do { do {
let n = await page.locator(game_sel).count(); let n = await page.locator(game_sel).count();
console.log('Number of free unclaimed games in external stores:', n); console.log('Number of free unclaimed games (external stores):', n);
const card = await page.$(game_sel); const card = await page.$(game_sel);
if (!card) break; if (!card) break;
const title = await (await card.$('h3')).innerText(); const title = await (await card.$('h3')).innerText();