aliexpress: use patchright, keep fingerprint-injector for mobile view
claiming coins should work, but can only test tomorrow
This commit is contained in:
parent
3156c03b03
commit
4a19e5775e
1 changed files with 17 additions and 9 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra
|
// import { firefox } from 'playwright-firefox';
|
||||||
|
import { chromium } from 'patchright';
|
||||||
import { datetime, filenamify, prompt, handleSIGINT } from './src/util.js';
|
import { datetime, filenamify, prompt, handleSIGINT } from './src/util.js';
|
||||||
import { cfg } from './src/config.js';
|
import { cfg } from './src/config.js';
|
||||||
|
|
||||||
// using https://github.com/apify/fingerprint-suite worked, but has no launchPersistentContext...
|
// can probably be removed and hard-code headers for mobile view
|
||||||
// from https://github.com/apify/fingerprint-suite/issues/162
|
|
||||||
import { FingerprintInjector } from 'fingerprint-injector';
|
import { FingerprintInjector } from 'fingerprint-injector';
|
||||||
import { FingerprintGenerator } from 'fingerprint-generator';
|
import { FingerprintGenerator } from 'fingerprint-generator';
|
||||||
|
|
||||||
|
|
@ -12,13 +12,14 @@ const { fingerprint, headers } = new FingerprintGenerator().getFingerprint({
|
||||||
operatingSystems: ['android'],
|
operatingSystems: ['android'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const context = await firefox.launchPersistentContext(cfg.dir.browser, {
|
const context = await chromium.launchPersistentContext(cfg.dir.browser, {
|
||||||
headless: cfg.headless,
|
headless: cfg.headless,
|
||||||
// viewport: { width: cfg.width, height: cfg.height },
|
// 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
|
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
|
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
|
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
|
||||||
handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved
|
handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved
|
||||||
|
// e.g. for coins, mobile view is needed, otherwise it just says to install the app
|
||||||
userAgent: fingerprint.navigator.userAgent,
|
userAgent: fingerprint.navigator.userAgent,
|
||||||
viewport: {
|
viewport: {
|
||||||
width: fingerprint.screen.width,
|
width: fingerprint.screen.width,
|
||||||
|
|
@ -27,6 +28,10 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, {
|
||||||
extraHTTPHeaders: {
|
extraHTTPHeaders: {
|
||||||
'accept-language': headers['accept-language'],
|
'accept-language': headers['accept-language'],
|
||||||
},
|
},
|
||||||
|
// https://peter.sh/experiments/chromium-command-line-switches/
|
||||||
|
args: [
|
||||||
|
'--hide-crash-restore-bubble',
|
||||||
|
],
|
||||||
});
|
});
|
||||||
handleSIGINT(context);
|
handleSIGINT(context);
|
||||||
// await stealth(context);
|
// await stealth(context);
|
||||||
|
|
@ -81,11 +86,14 @@ const urls = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const coins = async () => {
|
const coins = async () => {
|
||||||
// await auth(urls.coins);
|
const collectBtn = page.locator('div:has-text("Collect")').first();
|
||||||
await Promise.any([page.locator('.checkin-button').click(), page.locator('.addcoin').waitFor()]);
|
const moreBtn = page.locator('div:has-text("Earn more coins")').first();
|
||||||
console.log('Coins:', await page.locator('.mycoin-content-right-money').innerText());
|
await Promise.any([collectBtn.click(), moreBtn.waitFor()]);
|
||||||
console.log('Streak:', await page.locator('.title-box').innerText());
|
console.log(await page.locator('.marquee-content:has-text(" coins")').first().innerText());
|
||||||
console.log('Tomorrow:', await page.locator('.addcoin').innerText());
|
const n = (await page.locator('.marquee-item:has-text(" coins")').first().innerText()).replace(' coins', '');
|
||||||
|
console.log('Coins:', n);
|
||||||
|
// console.log('Streak:', await page.locator('.title-box').innerText());
|
||||||
|
// console.log('Tomorrow:', await page.locator('.addcoin').innerText());
|
||||||
};
|
};
|
||||||
|
|
||||||
// const grow = async () => {
|
// const grow = async () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue