* fixing sonar issues
This commit is contained in:
parent
ae9e79adf3
commit
731785cd12
3 changed files with 13 additions and 17 deletions
|
|
@ -97,7 +97,7 @@ Available options/variables and their default values:
|
||||||
| PS_PASSWORD | | PlayStation password for login. Overrides PASSWORD. |
|
| PS_PASSWORD | | PlayStation password for login. Overrides PASSWORD. |
|
||||||
| PS_OTPKEY | | PlayStation MFA OTP key. |
|
| PS_OTPKEY | | PlayStation MFA OTP key. |
|
||||||
| PS_LOCALE | en-us | Configurable locale to use the store. Examples are en-us, en-gb, de-at, ... |
|
| PS_LOCALE | en-us | Configurable locale to use the store. Examples are en-us, en-gb, de-at, ... |
|
||||||
| PS_PLUS_GAMES | 1 | Claim monthly ps plus games. Requires PS Plus Essential or higher subscription. |
|
| PS_PLUS_GAMES | 0 | Claim monthly ps plus games. Requires PS Plus Essential or higher subscription. |
|
||||||
| PS_GAME_CATALOG | 0 | Claim over 400 game catalog games. Requires PS Extra or higher. |
|
| PS_GAME_CATALOG | 0 | Claim over 400 game catalog games. Requires PS Extra or higher. |
|
||||||
| PS_CLASSICS_CATALOG | 0 | Currently not implemented! Requires PS Extra or higher. |
|
| PS_CLASSICS_CATALOG | 0 | Currently not implemented! Requires PS Extra or higher. |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ export const cfg = {
|
||||||
ps_email: process.env.PS_EMAIL || process.env.EMAIL,
|
ps_email: process.env.PS_EMAIL || process.env.EMAIL,
|
||||||
ps_password: process.env.PS_PASSWORD || process.env.PASSWORD,
|
ps_password: process.env.PS_PASSWORD || process.env.PASSWORD,
|
||||||
ps_otpkey: process.env.PS_OTPKEY,
|
ps_otpkey: process.env.PS_OTPKEY,
|
||||||
ps_locale: "en-us" || process.env.PS_LOCALE,
|
ps_locale: process.env.PS_LOCALE || "en-us",
|
||||||
ps_plus_games: true || process.env.PS_PLUS_GAMES == '1',
|
ps_plus_games: process.env.PS_PLUS_GAMES == '1',
|
||||||
ps_game_catalog: false || process.env.PS_GAME_CATALOG == '1',
|
ps_game_catalog: process.env.PS_GAME_CATALOG == '1',
|
||||||
ps_classics_catalog: false || process.env.PS_CLASSICS_CATALOG == '1',
|
ps_classics_catalog: process.env.PS_CLASSICS_CATALOG == '1',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
stealth,
|
stealth,
|
||||||
} from "./util.js";
|
} from "./util.js";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { existsSync, writeFileSync } from "fs";
|
import { existsSync } from "fs";
|
||||||
import { cfg } from "./config.js";
|
import { cfg } from "./config.js";
|
||||||
|
|
||||||
// ### SETUP
|
// ### SETUP
|
||||||
|
|
@ -36,11 +36,10 @@ export async function setup() {
|
||||||
// channel: 'chrome', // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
|
// channel: 'chrome', // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
|
||||||
headless: cfg.headless,
|
headless: cfg.headless,
|
||||||
viewport: { width: cfg.width, height: cfg.height },
|
viewport: { width: cfg.width, height: cfg.height },
|
||||||
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36', // see replace of Headless in util.newStealthContext. TODO Windows UA enough to avoid 'device not supported'? update if browser is updated?
|
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36',
|
||||||
// userAgent for firefox: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0
|
|
||||||
locale: "en-US", // ignore OS locale to be sure to have english text for locators
|
locale: "en-US", // ignore OS locale to be sure to have english text for locators
|
||||||
recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800
|
recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined,
|
||||||
recordHar: cfg.record ? { path: `data/record/eg-${datetime()}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools
|
recordHar: cfg.record ? { path: `data/record/eg-${datetime()}.har` } : undefined,
|
||||||
args: [ // https://peter.sh/experiments/chromium-command-line-switches
|
args: [ // https://peter.sh/experiments/chromium-command-line-switches
|
||||||
// don't want to see bubble 'Restore pages? Chrome didn't shut down correctly.'
|
// don't want to see bubble 'Restore pages? Chrome didn't shut down correctly.'
|
||||||
// '--restore-last-session', // does not apply for crash/killed
|
// '--restore-last-session', // does not apply for crash/killed
|
||||||
|
|
@ -250,7 +249,7 @@ async function claimGame(url) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var prefix;
|
let prefix;
|
||||||
if (url.includes("store.playstation.com")) {
|
if (url.includes("store.playstation.com")) {
|
||||||
const gameDiv = await page.locator(".psw-l-anchor").first();
|
const gameDiv = await page.locator(".psw-l-anchor").first();
|
||||||
if (gameDiv.isVisible()) {
|
if (gameDiv.isVisible()) {
|
||||||
|
|
@ -385,11 +384,8 @@ async function claimGameCatalog() {
|
||||||
|
|
||||||
const catalogGameUrls = await Promise.all(
|
const catalogGameUrls = await Promise.all(
|
||||||
catalogGames.map(async (catalogGame) => {
|
catalogGames.map(async (catalogGame) => {
|
||||||
var urlSlug = await catalogGame.getAttribute("href");
|
const urlSlug = await catalogGame.getAttribute("href");
|
||||||
|
return urlSlug.replace("en-gb", cfg.ps_locale).replace("en-us", cfg.ps_locale).substring(0, urlSlug.indexOf("?"));
|
||||||
urlSlug = urlSlug.replace("en-gb", cfg.ps_locale).replace("en-us", cfg.ps_locale).substring(0, urlSlug.indexOf("?"));
|
|
||||||
//console.log(urlSlug);
|
|
||||||
return urlSlug; // url may have anchor tag, remove it
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
console.log("Total catalog games:", catalogGameUrls.length);
|
console.log("Total catalog games:", catalogGameUrls.length);
|
||||||
|
|
@ -403,7 +399,7 @@ async function claimGameCatalog() {
|
||||||
|
|
||||||
function isClaimedUrl(url) {
|
function isClaimedUrl(url) {
|
||||||
try {
|
try {
|
||||||
var status = db.data[user][url.split("/").filter((x) => !!x).pop()]["status"];
|
const status = db.data[user][url.split("/").filter((x) => !!x).pop()]["status"];
|
||||||
return status === "existed" || status === "claimed";
|
return status === "existed" || status === "claimed";
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue