pg: gaming.amazon.com -> luna.amazon.com

This commit is contained in:
Ralf Vogler 2025-10-28 15:39:25 +01:00
parent f7e4d05804
commit faf3a590a4

View file

@ -8,7 +8,8 @@ import { cfg } from './src/config.js';
const screenshot = (...a) => resolve(cfg.dir.screenshots, 'prime-gaming', ...a); const screenshot = (...a) => resolve(cfg.dir.screenshots, 'prime-gaming', ...a);
// const URL_LOGIN = 'https://www.amazon.de/ap/signin'; // wrong. needs some session args to be valid? // const URL_LOGIN = 'https://www.amazon.de/ap/signin'; // wrong. needs some session args to be valid?
const URL_CLAIM = 'https://gaming.amazon.com/home'; const BASE_URL = 'https://luna.amazon.com';
const URL_CLAIM = `${BASE_URL}/claims/home`;
console.log(datetime(), 'started checking prime-gaming'); console.log(datetime(), 'started checking prime-gaming');
@ -84,7 +85,7 @@ try {
process.exit(1); process.exit(1);
} }
} }
await page.waitForURL('https://gaming.amazon.com/home?signedIn=true'); await page.waitForURL(`${BASE_URL}/claims/home?signedIn=true`);
if (!cfg.debug) context.setDefaultTimeout(cfg.timeout); if (!cfg.debug) context.setDefaultTimeout(cfg.timeout);
} }
user = await page.locator('[data-a-target="user-dropdown-first-name-text"]').first().innerText(); user = await page.locator('[data-a-target="user-dropdown-first-name-text"]').first().innerText();
@ -158,7 +159,7 @@ try {
await card.scrollIntoViewIfNeeded(); await card.scrollIntoViewIfNeeded();
const title = await (await card.locator('.item-card-details__body__primary')).innerText(); const title = await (await card.locator('.item-card-details__body__primary')).innerText();
const slug = await (await card.locator('a')).getAttribute('href'); const slug = await (await card.locator('a')).getAttribute('href');
const url = 'https://gaming.amazon.com' + slug.split('?')[0]; const url = BASE_URL + slug.split('?')[0];
console.log('Current free game:', chalk.blue(title)); console.log('Current free game:', chalk.blue(title));
if (cfg.pg_timeLeft && await skipBasedOnTime(url)) continue; if (cfg.pg_timeLeft && await skipBasedOnTime(url)) continue;
if (cfg.dryrun) continue; if (cfg.dryrun) continue;
@ -176,7 +177,7 @@ try {
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) 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)
const title = await card.locator('.item-card-details__body__primary').innerText(); const title = await card.locator('.item-card-details__body__primary').innerText();
const slug = await card.locator('a:has-text("Claim")').first().getAttribute('href'); const slug = await card.locator('a:has-text("Claim")').first().getAttribute('href');
const url = 'https://gaming.amazon.com' + slug.split('?')[0]; const url = BASE_URL + slug.split('?')[0];
// await (await card.$('text=Claim')).click(); // goes to URL of game, no need to wait // await (await card.$('text=Claim')).click(); // goes to URL of game, no need to wait
external_info.push({ title, url }); external_info.push({ title, url });
} }
@ -381,7 +382,7 @@ try {
const dlcs = await Promise.all(cards.map(async card => ({ const dlcs = await Promise.all(cards.map(async card => ({
game: await card.locator('.item-card-details__body p').innerText(), game: await card.locator('.item-card-details__body p').innerText(),
title: await card.locator('.item-card-details__body__primary').innerText(), title: await card.locator('.item-card-details__body__primary').innerText(),
url: 'https://gaming.amazon.com' + await card.locator('a').first().getAttribute('href'), url: BASE_URL + await card.locator('a').first().getAttribute('href'),
}))); })));
// console.log(dlcs); // console.log(dlcs);