playstation: handle purchased titles, add better waiting for login status

This commit is contained in:
Omair 2023-07-16 19:18:56 -04:00
parent e2a59dd794
commit f0cf3436f5

View file

@ -63,7 +63,7 @@ async function main() {
}
async function performLogin() {
await page.goto(URL_CLAIM, { waitUntil: "domcontentloaded" }); // default 'load' takes forever
await page.goto(URL_CLAIM, { waitUntil: "networkidle" }); // default 'load' takes forever
const signInLocator = page.locator('span:has-text("Sign in")').first();
const profileIconLocator = page.locator(".profile-icon").first();
@ -233,13 +233,16 @@ async function redeemFreeGames() {
const inLibrary = gameCard
.locator('span:has-text("In library")')
.first();
const purchased = gameCard
.locator('span:has-text("Purchased")')
.first();
const addToLibrary = gameCard
.locator('span:has-text("Add to Library")')
.nth(1);
await Promise.any([addToLibrary.waitFor(), inLibrary.waitFor()]);
await Promise.any([addToLibrary.waitFor(), purchased.waitFor(), inLibrary.waitFor()]);
if (await inLibrary.isVisible()) {
if (await inLibrary.isVisible() || await purchased.isVisible()) {
console.log(" Already in library! Nothing to claim.");
notify_game.status = "existed";
db.data[user][game_id].status ||= "existed"; // does not overwrite claimed or failed