Current free game title in blue

This commit is contained in:
Ralf Vogler 2025-04-15 17:26:27 +02:00
parent 04d1b7ea9e
commit 726db4527b
3 changed files with 8 additions and 6 deletions

View file

@ -150,14 +150,14 @@ try {
if (isNew) await p.close();
return daysLeft > cfg.pg_timeLeft;
}
console.log('Number of free unclaimed games (Prime Gaming):', internal.length);
console.log('\nNumber of free unclaimed games (Prime Gaming):', internal.length);
// claim games in internal store
for (const card of internal) {
await card.scrollIntoViewIfNeeded();
const title = await (await card.$('.item-card-details__body__primary')).innerText();
const slug = await (await card.$('a')).getAttribute('href');
const url = 'https://gaming.amazon.com' + slug.split('?')[0];
console.log('Current free game:', title);
console.log('Current free game:', chalk.blue(title));
if (cfg.pg_timeLeft && await skipBasedOnTime(url)) continue;
if (cfg.dryrun) continue;
if (cfg.interactive && !await confirm()) continue;
@ -168,7 +168,7 @@ try {
// console.log('Image:', img);
await card.screenshot({ path: screenshot('internal', `${filenamify(title)}.png`) });
}
console.log('Number of free unclaimed games (external stores):', external.length);
console.log('\nNumber of free unclaimed games (external stores):', external.length);
// claim games in external/linked stores. Linked: origin.com, epicgames.com; Redeem-key: gog.com, legacygames.com, microsoft
const external_info = [];
for (const card of external) { // need to get data incl. URLs in this loop and then navigate in another, otherwise .all() would update after coming back and .elementHandles() like above would lead to error due to page navigation: elementHandle.$: Protocol error (Page.adoptNode)
@ -180,7 +180,7 @@ try {
}
// external_info = [ { title: 'Fallout 76 (XBOX)', url: 'https://gaming.amazon.com/fallout-76-xbox-fgwp/dp/amzn1.pg.item.9fe17d7b-b6c2-4f58-b494-cc4e79528d0b?ingress=amzn&ref_=SM_Fallout76XBOX_S01_FGWP_CRWN' } ];
for (const { title, url } of external_info) {
console.log('Current free game:', title); // , url);
console.log('Current free game:', chalk.blue(title)); // , url);
await page.goto(url, { waitUntil: 'domcontentloaded' });
if (cfg.debug) await page.pause();
const item_text = await page.innerText('[data-a-target="DescriptionItemDetails"]');