Fix eslint no-empty and clean tests
Some checks failed
build-and-push / lint (push) Failing after 4s
build-and-push / sonar (push) Has been skipped
build-and-push / docker (push) Has been skipped

This commit is contained in:
nocci 2025-12-30 16:13:15 +00:00
parent 5f919039ab
commit 3fd861f134
4 changed files with 48 additions and 17 deletions

View file

@ -97,13 +97,17 @@ try {
await page.waitForSelector('.h_captcha_challenge iframe', { timeout: 15000 });
console.error('Got a captcha during login (likely due to too many attempts)! You may solve it in the browser, get a new IP or try again in a few hours.');
await notify('epic-games: got captcha during login. Please check.');
} catch {}
} catch (e) {
return;
}
})();
void (async () => {
try {
await page.waitForSelector('p:has-text("Incorrect response.")', { timeout: 15000 });
console.error('Incorrect response for captcha!');
} catch {}
} catch (e) {
return;
}
})();
await page.fill('#email', email);
const password = email && (cfg.eg_password || await prompt({ type: 'password', message: 'Enter password' }));
@ -118,7 +122,9 @@ try {
await error.waitFor({ timeout: 15000 });
console.error('Login error:', await error.innerText());
console.log('Please login in the browser!');
} catch {}
} catch (e) {
return;
}
})();
void (async () => {
try {
@ -127,7 +133,9 @@ try {
const otp = cfg.eg_otpkey && authenticator.generate(cfg.eg_otpkey) || await prompt({ type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!' }); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them
await page.locator('input[name="code-input-0"]').pressSequentially(otp.toString());
await page.click('button[type="submit"]');
} catch {}
} catch (e) {
return;
}
})();
}
await page.waitForURL(URL_CLAIM);
@ -228,7 +236,9 @@ try {
console.log(' Accept End User License Agreement (only needed once)');
await page.locator('input#agree').check();
await page.locator('button:has-text("Accept")').click();
} catch {}
} catch (e) {
return;
}
})();
// it then creates an iframe for the purchase
@ -251,7 +261,9 @@ try {
}
await iframe.locator('input.payment-pin-code__input').first().pressSequentially(cfg.eg_parentalpin);
await iframe.locator('button:has-text("Continue")').click({ delay: 11 });
} catch {}
} catch (e) {
return;
}
})();
if (cfg.debug) await page.pause();
@ -271,7 +283,9 @@ try {
try {
await btnAgree.waitFor({ timeout: 10000 });
await btnAgree.click();
} catch {}
} catch (e) {
return;
}
})(); // EU: wait for and click 'I Agree'
try {
// context.setDefaultTimeout(100 * 1000); // give time to solve captcha, iframe goes blank after 60s?
@ -281,14 +295,18 @@ try {
await captcha.waitFor({ timeout: 10000 });
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 for.\nGame link: ${url}`);
} catch {}
} catch (e) {
return;
}
})(); // may time out if not shown
void (async () => {
try {
await iframe.locator('.payment__errors:has-text("Failed to challenge captcha, please try again later.")').waitFor({ timeout: 10000 });
console.error(' Failed to challenge captcha, please try again later.');
await notify('epic-games: failed to challenge captcha. Please check.');
} catch {}
} catch (e) {
return;
}
})();
await page.locator('text=Thanks for your order!').waitFor({ state: 'attached' });
db.data[user][game_id].status = 'claimed';

8
gog.js
View file

@ -69,14 +69,18 @@ try {
await iframe.locator('#second_step_authentication_token_letter_1').pressSequentially(otp.toString(), { delay: 10 });
await iframe.locator('#second_step_authentication_send').click();
await page.waitForTimeout(1000);
} catch {}
} catch (e) {
return;
}
})();
void (async () => {
try {
await iframe.locator('text=Invalid captcha').waitFor({ timeout: 15000 });
console.error('Got a captcha during login (likely due to too many attempts)! You may solve it in the browser, get a new IP or try again in a few hours.');
notify('gog: got captcha during login. Please check.');
} catch {}
} catch (e) {
return;
}
})();
await page.waitForSelector('#menuUsername');
} else {

View file

@ -1,4 +1,3 @@
/* eslint-disable no-constant-condition */
import { delay, html_game_list, notify } from '../src/util.js';
import { cfg } from '../src/config.js';

View file

@ -64,7 +64,9 @@ try {
await page.waitForSelector('#h_captcha_challenge_login_prod iframe', { timeout: 15000 });
console.error('Got a captcha during login (likely due to too many attempts)! You may solve it in the browser, get a new IP or try again in a few hours.');
notify('unrealengine: got captcha during login. Please check.');
} catch {}
} catch (e) {
return;
}
})();
void (async () => {
try {
@ -73,7 +75,9 @@ try {
const otp = cfg.eg_otpkey && authenticator.generate(cfg.eg_otpkey) || await prompt({ type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!' }); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them
await page.locator('input[name="code-input-0"]').pressSequentially(otp.toString());
await page.click('button[type="submit"]');
} catch {}
} catch (e) {
return;
}
})();
} else {
console.log('Waiting for you to login in the browser.');
@ -143,7 +147,9 @@ try {
await page.locator('[name=accept-label]').check({ timeout: 10000 });
console.log('Accept End User License Agreement');
await page.locator('span:text-is("Accept")').click(); // otherwise matches 'Accept All Cookies'
} catch {}
} catch (e) {
return;
}
})();
await page.waitForSelector('#webPurchaseContainer iframe');
const iframe = page.frameLocator('#webPurchaseContainer iframe');
@ -164,7 +170,9 @@ try {
try {
await btnAgree.waitFor({ timeout: 10000 });
await btnAgree.click();
} catch {}
} catch (e) {
return;
}
})(); // EU: wait for and click 'I Agree'
try {
// context.setDefaultTimeout(100 * 1000); // give time to solve captcha, iframe goes blank after 60s?
@ -173,7 +181,9 @@ try {
try {
await captcha.waitFor({ timeout: 10000 });
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.');
} catch {}
} catch (e) {
return;
}
})(); // may time out if not shown
await page.waitForSelector('text=Thank you');
for (const id of ids) {