playstation: remove anchor link from game url

This commit is contained in:
Omair 2023-07-18 16:40:05 -04:00
parent f0cf3436f5
commit 6a5cbdb344

View file

@ -139,7 +139,7 @@ async function signInToPSN() {
"playstation-plus: got captcha during login. Please check." "playstation-plus: got captcha during login. Please check."
); );
}) })
.catch((_) => {}); .catch((_) => { });
// handle MFA, but don't await it // handle MFA, but don't await it
page.locator('input[title="Enter Code"]') page.locator('input[title="Enter Code"]')
@ -167,7 +167,7 @@ async function signInToPSN() {
.click(); // Trust this Browser .click(); // Trust this Browser
await page.click("button.primary-button"); await page.click("button.primary-button");
}) })
.catch((_) => {}); .catch((_) => { });
} else { } else {
console.log("Waiting for you to login in the browser."); console.log("Waiting for you to login in the browser.");
await notify( await notify(
@ -206,9 +206,10 @@ async function redeemFreeGames() {
.locator(".cta__primary") .locator(".cta__primary")
.getAttribute("href"); .getAttribute("href");
// standardize URLs // standardize URLs
return urlSlug.charAt(0) === "/" return (urlSlug.charAt(0) === "/"
? `https://www.playstation.com${urlSlug}` ? `https://www.playstation.com${urlSlug}` // base url may not be present, add it back
: urlSlug; : urlSlug)
.split('#').shift(); // url may have anchor tag, remove it
}) })
); );
console.log("Free games:", monthlyGamesPageLinks); console.log("Free games:", monthlyGamesPageLinks);