Skip to content

Commit 92cb32f

Browse files
committed
ae: try fingerprint-injector
1 parent 90e3400 commit 92cb32f

File tree

3 files changed

+420
-8
lines changed

3 files changed

+420
-8
lines changed

aliexpress.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,35 @@ import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdate
22
import { datetime, filenamify, prompt, handleSIGINT, stealth } from './src/util.js';
33
import { cfg } from './src/config.js';
44

5+
// using https://github.com/apify/fingerprint-suite worked, but has no launchPersistentContext...
6+
// from https://github.com/apify/fingerprint-suite/issues/162
7+
import { FingerprintInjector } from 'fingerprint-injector';
8+
import { FingerprintGenerator } from 'fingerprint-generator';
9+
10+
const { fingerprint, headers } = new FingerprintGenerator().getFingerprint({
11+
devices: ["mobile"],
12+
operatingSystems: ["android"],
13+
});
14+
515
const context = await firefox.launchPersistentContext(cfg.dir.browser, {
616
headless: cfg.headless,
7-
viewport: { width: cfg.width, height: cfg.height },
17+
// viewport: { width: cfg.width, height: cfg.height },
818
locale: 'en-US', // ignore OS locale to be sure to have english text for locators -> done via /en in URL
919
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
10-
recordHar: cfg.record ? { path: `data/record/gog-${filenamify(datetime())}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools
20+
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
1121
handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved
22+
userAgent: fingerprint.navigator.userAgent,
23+
viewport: {
24+
width: fingerprint.screen.width,
25+
height: fingerprint.screen.height,
26+
},
27+
extraHTTPHeaders: {
28+
'accept-language': headers['accept-language'],
29+
},
1230
});
1331
handleSIGINT(context);
14-
await stealth(context);
32+
// await stealth(context);
33+
await new FingerprintInjector().attachFingerprintToPlaywright(context, { fingerprint, headers });
1534

1635
context.setDefaultTimeout(cfg.debug ? 0 : cfg.timeout);
1736

@@ -88,11 +107,11 @@ const merge = async () => {
88107
try {
89108
// await coins();
90109
await [
91-
coins,
110+
// coins,
92111
// grow,
93112
// gogo,
94113
// euro,
95-
// merge,
114+
merge,
96115
].reduce((a, f) => a.then(async _ => { await auth(urls[f.name]); await f(); console.log() }), Promise.resolve());
97116

98117
// await page.pause();

0 commit comments

Comments
 (0)