From e5935faa131187f54cb8b8afe726dd96fcb11fce Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Tue, 7 Nov 2023 15:20:58 +0100 Subject: [PATCH] sonarcloud fixes --- Dockerfile | 2 +- prime-gaming.js | 3 +-- util.js | 15 --------------- xbox.js | 2 -- 4 files changed, 2 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index f44a893..a8c5e24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,7 +64,7 @@ RUN npm install COPY . . # Shell scripts need Linux line endings. On Windows, git might be configured to check out dos/CRLF line endings, so we convert them for those people in case they want to build the image. They could also use --config core.autocrlf=input -RUN dos2unix *.sh && chmod +x *.sh +RUN dos2unix ./*.sh && chmod +x ./*.sh COPY docker-entrypoint.sh /usr/local/bin/ ARG COMMIT="" diff --git a/prime-gaming.js b/prime-gaming.js index 8e630e6..5acdb06 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -206,7 +206,7 @@ try { // {"reason":"Invalid or no captcha"} // {"reason":"code_used"} // {"reason":"code_not_found"} - if (reason && reason.includes('captcha')) { + if (reason?.includes('captcha')) { redeem_action = 'redeem (got captcha)'; console.error(' Got captcha; could not redeem!'); } else if (reason == 'code_used') { @@ -228,7 +228,6 @@ try { console.log(' Redeemed successfully.'); db.data[user][title].status = 'claimed and redeemed'; } else { - redeem_action = 'redeemed?'; console.debug(` Response 2: ${r2t}`); console.log(' Unknown Response 2 - please report in https://github.com/vogler/free-games-claimer/issues/5'); } diff --git a/util.js b/util.js index 9904486..5b8bef0 100644 --- a/util.js +++ b/util.js @@ -27,21 +27,6 @@ export const handleSIGINT = (context = null) => process.on('SIGINT', async () => if (context) await context.close(); // in order to save recordings also on SIGINT, we need to disable Playwright's handleSIGINT and close the context ourselves }); -// stealth with playwright: https://github.com/berstend/puppeteer-extra/issues/454#issuecomment-917437212 -// gets userAgent and then removes "Headless" from it -const newStealthContext = async (browser, contextOptions = {}, debug = false) => { - if (!debug) { // only need to fix userAgent in headless mode - const dummyContext = await browser.newContext(); - const originalUserAgent = await (await dummyContext.newPage()).evaluate(() => navigator.userAgent); - await dummyContext.close(); - // console.log('originalUserAgent:', originalUserAgent); // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/96.0.4664.110 Safari/537.36 - contextOptions = { - ...contextOptions, - userAgent: originalUserAgent.replace("Headless", ""), // HeadlessChrome -> Chrome, TODO needed? - }; - } -}; - export const stealth = async (context) => { // stealth with playwright: https://github.com/berstend/puppeteer-extra/issues/454#issuecomment-917437212 // https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth/evasions diff --git a/xbox.js b/xbox.js index 501f4f1..a2150f1 100644 --- a/xbox.js +++ b/xbox.js @@ -8,8 +8,6 @@ import { notify, prompt, } from "./util.js"; -import path from "path"; -import { existsSync, writeFileSync } from "fs"; import { cfg } from "./config.js"; // ### SETUP