Skip to content

Commit

Permalink
fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vogler committed Nov 7, 2023
1 parent 6a34cb5 commit e4e4f2e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
10 changes: 5 additions & 5 deletions epic-games.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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();
1 change: 1 addition & 0 deletions notify-test.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion prime-gaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,5 @@ try {
notify(`prime-gaming (${user}):<br>${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();
7 changes: 4 additions & 3 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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}`);
Expand Down
7 changes: 3 additions & 4 deletions version.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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
Expand All @@ -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!');
}

0 comments on commit e4e4f2e

Please sign in to comment.