pg: patchright: .$ -> .locator, fix 29576f0af0

https://github.com/vogler/free-games-claimer/issues/484#issuecomment-2923360239
This commit is contained in:
Ralf Vogler 2025-06-04 15:54:19 +02:00
parent d2bfddb5f4
commit 0890a7a073

View file

@ -163,10 +163,10 @@ try {
if (cfg.pg_timeLeft && await skipBasedOnTime(url)) continue;
if (cfg.dryrun) continue;
if (cfg.interactive && !await confirm()) continue;
await (await card.$('.tw-button:has-text("Claim")')).click();
await card.locator('.tw-button:has-text("Claim")').click();
db.data[user][title] ||= { title, time: datetime(), url, store: 'internal' };
notify_games.push({ title, status: 'claimed', url });
// const img = await (await card.$('img.tw-image')).getAttribute('src');
// const img = await card.locator('img.tw-image').getAttribute('src');
// console.log('Image:', img);
await card.screenshot({ path: screenshot('internal', `${filenamify(title)}.png`) });
}
@ -219,7 +219,7 @@ try {
const code = await Promise.any([page.inputValue('input[type="text"]'), page.textContent('[data-a-target="ClaimStateClaimCodeContent"]').then(s => s.replace('Your code: ', ''))]); // input: Legacy Games; text: gog.com
console.log(' Code to redeem game:', chalk.blue(code));
if (store == 'legacy games') { // may be different URL like https://legacygames.com/primeday/puzzleoftheyear/
redeem[store] = await (await page.$('li:has-text("Click here") a')).getAttribute('href'); // full text: Click here to enter your redemption code.
redeem[store] = await page.locator('li:has-text("Click here") a').getAttribute('href'); // full text: Click here to enter your redemption code.
}
let redeem_url = redeem[store];
if (store == 'gog.com') redeem_url += '/' + code; // to log and notify, but can't use for goto below (captcha)