diff --git a/epic-games.js b/epic-games.js index 8fc78ca..dcfce73 100644 --- a/epic-games.js +++ b/epic-games.js @@ -94,7 +94,7 @@ try { await notify('epic-games: got captcha during login. Please check.'); }).catch(_ => { }); page.waitForSelector('h6:has-text("Incorrect response.")').then(async () => { - console.error('Incorrect repsonse for captcha!') + console.error('Incorrect repsonse for captcha!'); }).catch(_ => { }); // handle MFA, but don't await it page.waitForURL('**/id/login/mfa**').then(async () => { @@ -128,7 +128,7 @@ try { // rarely there are no free games available -> catch Timeout // TODO would be better to wait for alternative like 'coming soon' instead of waiting for timeout // see https://github.com/vogler/free-games-claimer/issues/210#issuecomment-1727420943 - console.error('Seems like currently there are no free games available in your region...') + console.error('Seems like currently there are no free games available in your region...'); // urls below should then be an empty list }); // clicking on `game_sel` sometimes led to a 404, see https://github.com/vogler/free-games-claimer/issues/25 @@ -227,8 +227,8 @@ try { const captcha = iframe.locator('#h_captcha_challenge_checkout_free_prod iframe'); captcha.waitFor().then(async () => { // don't await, since element may not be shown // console.info(' Got hcaptcha challenge! NopeCHA extension will likely solve it.') - console.error(' Got hcaptcha challenge! Lost trust due to too many login attempts? You can solve the captcha in the browser or get a new IP address.') - await notify('epic-games: got captcha challenge right before claim. Use VNC to solve it manually.') + console.error(' Got hcaptcha challenge! Lost trust due to too many login attempts? You can solve the captcha in the browser or get a new IP address.'); + await notify('epic-games: got captcha challenge right before claim. Use VNC to solve it manually.'); // await page.waitForTimeout(2000); // const p = path.resolve(cfg.dir.screenshots, 'epic-games', 'captcha', `${filenamify(datetime())}.png`); // await captcha.screenshot({ path: p }); @@ -269,5 +269,5 @@ try { } } if (cfg.debug) writeFileSync(path.resolve(cfg.dir.browser, 'cookies.json'), JSON.stringify(await context.cookies())); -if (page.video()) console.log('Recorded video:', await page.video().path()) +if (page.video()) console.log('Recorded video:', await page.video().path()); await context.close(); diff --git a/notify-test.js b/notify-test.js index d8f4dab..d138657 100644 --- a/notify-test.js +++ b/notify-test.js @@ -1,3 +1,4 @@ +/* eslint-disable no-constant-condition */ import { delay, html_game_list, notify } from "./util.js"; const URL_CLAIM = 'https://gaming.amazon.com/home'; // dummy URL diff --git a/prime-gaming.js b/prime-gaming.js index 5acdb06..ae7879e 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -394,5 +394,5 @@ try { notify(`prime-gaming (${user}):
${html_game_list(notify_games)}`); } } -if (page.video()) console.log('Recorded video:', await page.video().path()) +if (page.video()) console.log('Recorded video:', await page.video().path()); await context.close(); diff --git a/util.js b/util.js index 5b8bef0..0ab0912 100644 --- a/util.js +++ b/util.js @@ -74,11 +74,12 @@ const timeoutPlugin = timeout => enquirer => { // cancel prompt after timeout ms prompt.on('submit', _ => clearTimeout(t)); prompt.on('cancel', _ => clearTimeout(t)); }); -} +}; enquirer.use(timeoutPlugin(cfg.login_timeout)); // TODO may not want to have this timeout for all prompts; better extend Prompt and add a timeout prompt option // single prompt that just returns the non-empty value instead of an object +// @ts-ignore export const prompt = o => enquirer.prompt({name: 'name', type: 'input', message: 'Enter value', ...o}).then(r => r.name).catch(_ => {}); -export const confirm = o => prompt({type: 'confirm', message: 'Continue?', ...o}) +export const confirm = o => prompt({type: 'confirm', message: 'Continue?', ...o}); // notifications via apprise CLI import { exec } from 'child_process'; @@ -93,7 +94,7 @@ export const notify = (html) => new Promise((resolve, reject) => { if (error.message.includes('command not found')) { console.info('Run `pip install apprise`. See https://github.com/vogler/free-games-claimer#notifications'); } - return resolve(); + return reject(error); } if (stderr) console.error(`stderr: ${stderr}`); if (stdout) console.log(`stdout: ${stdout}`); diff --git a/version.js b/version.js index 1df93a1..d992afb 100644 --- a/version.js +++ b/version.js @@ -1,7 +1,6 @@ // check if running the latest version import {log} from 'console'; -import { readFileSync } from 'fs'; import { exec } from 'child_process'; const execp = (cmd) => new Promise((resolve, reject) => { @@ -19,7 +18,7 @@ const execp = (cmd) => new Promise((resolve, reject) => { }); }); -const git_main = () => readFileSync('.git/refs/heads/main').toString().trim(); +// const git_main = () => readFileSync('.git/refs/heads/main').toString().trim(); let sha, date; // if (existsSync('/.dockerenv')) { // did not work @@ -44,7 +43,7 @@ log('Local commit:', sha, new Date(date)); log('Online commit:', gh.sha, new Date(gh.commit.committer.date)); if (sha == gh.sha) { - log('Running the latest version!') + log('Running the latest version!'); } else { - log('Not running the latest version!') + log('Not running the latest version!'); }