Fix eslint no-empty and clean tests
This commit is contained in:
parent
5f919039ab
commit
3fd861f134
4 changed files with 48 additions and 17 deletions
|
|
@ -97,13 +97,17 @@ try {
|
||||||
await page.waitForSelector('.h_captcha_challenge iframe', { timeout: 15000 });
|
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.');
|
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.');
|
await notify('epic-games: got captcha during login. Please check.');
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
await page.waitForSelector('p:has-text("Incorrect response.")', { timeout: 15000 });
|
await page.waitForSelector('p:has-text("Incorrect response.")', { timeout: 15000 });
|
||||||
console.error('Incorrect response for captcha!');
|
console.error('Incorrect response for captcha!');
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
await page.fill('#email', email);
|
await page.fill('#email', email);
|
||||||
const password = email && (cfg.eg_password || await prompt({ type: 'password', message: 'Enter password' }));
|
const password = email && (cfg.eg_password || await prompt({ type: 'password', message: 'Enter password' }));
|
||||||
|
|
@ -118,7 +122,9 @@ try {
|
||||||
await error.waitFor({ timeout: 15000 });
|
await error.waitFor({ timeout: 15000 });
|
||||||
console.error('Login error:', await error.innerText());
|
console.error('Login error:', await error.innerText());
|
||||||
console.log('Please login in the browser!');
|
console.log('Please login in the browser!');
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
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
|
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.locator('input[name="code-input-0"]').pressSequentially(otp.toString());
|
||||||
await page.click('button[type="submit"]');
|
await page.click('button[type="submit"]');
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
await page.waitForURL(URL_CLAIM);
|
await page.waitForURL(URL_CLAIM);
|
||||||
|
|
@ -228,7 +236,9 @@ try {
|
||||||
console.log(' Accept End User License Agreement (only needed once)');
|
console.log(' Accept End User License Agreement (only needed once)');
|
||||||
await page.locator('input#agree').check();
|
await page.locator('input#agree').check();
|
||||||
await page.locator('button:has-text("Accept")').click();
|
await page.locator('button:has-text("Accept")').click();
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// it then creates an iframe for the purchase
|
// 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('input.payment-pin-code__input').first().pressSequentially(cfg.eg_parentalpin);
|
||||||
await iframe.locator('button:has-text("Continue")').click({ delay: 11 });
|
await iframe.locator('button:has-text("Continue")').click({ delay: 11 });
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if (cfg.debug) await page.pause();
|
if (cfg.debug) await page.pause();
|
||||||
|
|
@ -271,7 +283,9 @@ try {
|
||||||
try {
|
try {
|
||||||
await btnAgree.waitFor({ timeout: 10000 });
|
await btnAgree.waitFor({ timeout: 10000 });
|
||||||
await btnAgree.click();
|
await btnAgree.click();
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})(); // EU: wait for and click 'I Agree'
|
})(); // EU: wait for and click 'I Agree'
|
||||||
try {
|
try {
|
||||||
// context.setDefaultTimeout(100 * 1000); // give time to solve captcha, iframe goes blank after 60s?
|
// context.setDefaultTimeout(100 * 1000); // give time to solve captcha, iframe goes blank after 60s?
|
||||||
|
|
@ -281,14 +295,18 @@ try {
|
||||||
await captcha.waitFor({ timeout: 10000 });
|
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.');
|
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}`);
|
await notify(`epic-games: got captcha challenge for.\nGame link: ${url}`);
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})(); // may time out if not shown
|
})(); // may time out if not shown
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
await iframe.locator('.payment__errors:has-text("Failed to challenge captcha, please try again later.")').waitFor({ timeout: 10000 });
|
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.');
|
console.error(' Failed to challenge captcha, please try again later.');
|
||||||
await notify('epic-games: failed to challenge captcha. Please check.');
|
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' });
|
await page.locator('text=Thanks for your order!').waitFor({ state: 'attached' });
|
||||||
db.data[user][game_id].status = 'claimed';
|
db.data[user][game_id].status = 'claimed';
|
||||||
|
|
|
||||||
8
gog.js
8
gog.js
|
|
@ -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_token_letter_1').pressSequentially(otp.toString(), { delay: 10 });
|
||||||
await iframe.locator('#second_step_authentication_send').click();
|
await iframe.locator('#second_step_authentication_send').click();
|
||||||
await page.waitForTimeout(1000);
|
await page.waitForTimeout(1000);
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
try {
|
||||||
await iframe.locator('text=Invalid captcha').waitFor({ timeout: 15000 });
|
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.');
|
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.');
|
notify('gog: got captcha during login. Please check.');
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
await page.waitForSelector('#menuUsername');
|
await page.waitForSelector('#menuUsername');
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
/* eslint-disable no-constant-condition */
|
|
||||||
import { delay, html_game_list, notify } from '../src/util.js';
|
import { delay, html_game_list, notify } from '../src/util.js';
|
||||||
import { cfg } from '../src/config.js';
|
import { cfg } from '../src/config.js';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,9 @@ try {
|
||||||
await page.waitForSelector('#h_captcha_challenge_login_prod iframe', { timeout: 15000 });
|
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.');
|
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.');
|
notify('unrealengine: got captcha during login. Please check.');
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
void (async () => {
|
void (async () => {
|
||||||
try {
|
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
|
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.locator('input[name="code-input-0"]').pressSequentially(otp.toString());
|
||||||
await page.click('button[type="submit"]');
|
await page.click('button[type="submit"]');
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
} else {
|
} else {
|
||||||
console.log('Waiting for you to login in the browser.');
|
console.log('Waiting for you to login in the browser.');
|
||||||
|
|
@ -143,7 +147,9 @@ try {
|
||||||
await page.locator('[name=accept-label]').check({ timeout: 10000 });
|
await page.locator('[name=accept-label]').check({ timeout: 10000 });
|
||||||
console.log('Accept End User License Agreement');
|
console.log('Accept End User License Agreement');
|
||||||
await page.locator('span:text-is("Accept")').click(); // otherwise matches 'Accept All Cookies'
|
await page.locator('span:text-is("Accept")').click(); // otherwise matches 'Accept All Cookies'
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
await page.waitForSelector('#webPurchaseContainer iframe');
|
await page.waitForSelector('#webPurchaseContainer iframe');
|
||||||
const iframe = page.frameLocator('#webPurchaseContainer iframe');
|
const iframe = page.frameLocator('#webPurchaseContainer iframe');
|
||||||
|
|
@ -164,7 +170,9 @@ try {
|
||||||
try {
|
try {
|
||||||
await btnAgree.waitFor({ timeout: 10000 });
|
await btnAgree.waitFor({ timeout: 10000 });
|
||||||
await btnAgree.click();
|
await btnAgree.click();
|
||||||
} catch {}
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
})(); // EU: wait for and click 'I Agree'
|
})(); // EU: wait for and click 'I Agree'
|
||||||
try {
|
try {
|
||||||
// context.setDefaultTimeout(100 * 1000); // give time to solve captcha, iframe goes blank after 60s?
|
// context.setDefaultTimeout(100 * 1000); // give time to solve captcha, iframe goes blank after 60s?
|
||||||
|
|
@ -173,7 +181,9 @@ try {
|
||||||
try {
|
try {
|
||||||
await captcha.waitFor({ timeout: 10000 });
|
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.');
|
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
|
})(); // may time out if not shown
|
||||||
await page.waitForSelector('text=Thank you');
|
await page.waitForSelector('text=Thank you');
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue