Clean Sonar findings: merge RUNs, drop commented code, update node imports
All checks were successful
build-and-push / lint (push) Successful in 4s
build-and-push / sonar (push) Successful in 11s
build-and-push / docker (push) Successful in 1m13s

This commit is contained in:
nocci 2025-12-30 15:39:11 +00:00
parent 37ffd09545
commit 405e801851
7 changed files with 44 additions and 72 deletions

View file

@ -14,7 +14,6 @@ const { fingerprint, headers } = new FingerprintGenerator().getFingerprint({
const context = await firefox.launchPersistentContext(cfg.dir.browser, {
headless: cfg.headless,
// viewport: { width: cfg.width, height: cfg.height },
locale: 'en-US', // ignore OS locale to be sure to have english text for locators -> done via /en in URL
recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800
recordHar: cfg.record ? { path: `data/record/aliexpress-${filenamify(datetime())}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools
@ -29,7 +28,6 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, {
},
});
handleSIGINT(context);
// await stealth(context);
await new FingerprintInjector().attachFingerprintToPlaywright(context, { fingerprint, headers });
context.setDefaultTimeout(cfg.debug ? 0 : cfg.timeout);
@ -41,10 +39,7 @@ const auth = async url => {
await page.goto(url, { waitUntil: 'domcontentloaded' });
// redirects to https://login.aliexpress.com/?return_url=https%3A%2F%2Fwww.aliexpress.com%2Fp%2Fcoin-pc-index%2Findex.html
await Promise.any([page.waitForURL(url => url.includes('login.aliexpress.com')).then(async () => {
// manual login
console.error('Not logged in! Will wait for 120s for you to login...');
// await page.waitForTimeout(120*1000);
// or try automated
page.locator('span:has-text("Switch account")').click().catch(() => {}); // sometimes no longer logged in, but previous user/email is pre-selected -> in this case we want to go back to the classic login
const login = page.locator('.login-container');
const email = cfg.ae_email || await prompt({ message: 'Enter email' });
@ -60,12 +55,8 @@ const auth = async url => {
const error = login.locator('.error-text');
error.waitFor().then(async () => console.error('Login error:', await error.innerText()));
await page.waitForURL(url);
// await page.addLocatorHandler(page.getByRole('button', { name: 'Accept cookies' }), btn => btn.click());
page.getByRole('button', { name: 'Accept cookies' }).click().then(() => console.log('Accepted cookies')).catch(() => { });
}), page.locator('#nav-user-account').waitFor()]).catch(() => {});
// await page.locator('#nav-user-account').hover();
// console.log('Logged in as:', await page.locator('.welcome-name').innerText());
};
// copied URLs from AliExpress app on tablet which has menu for the used webview
@ -82,7 +73,6 @@ const urls = {
/* eslint-disable no-unused-vars */
const coins = async () => {
// await auth(urls.coins);
await Promise.any([page.locator('.checkin-button').click(), page.locator('.addcoin').waitFor()]);
console.log('Coins:', await page.locator('.mycoin-content-right-money').innerText());
console.log('Streak:', await page.locator('.title-box').innerText());
@ -107,20 +97,13 @@ const merge = async () => {
/* eslint-enable no-unused-vars */
try {
// await coins();
await [
// coins,
// grow,
// gogo,
// euro,
merge,
].reduce((a, f) => a.then(async () => {
await auth(urls[f.name]);
await f();
console.log();
}), Promise.resolve());
// await page.pause();
} catch (error) {
process.exitCode ||= 1;
console.error('--- Exception:');