@xcanwin/manyoyo 5.1.5 → 5.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/plugin/playwright.js +32 -3
- package/package.json +1 -1
package/lib/plugin/playwright.js
CHANGED
|
@@ -56,6 +56,14 @@ const SCENE_DEFS = {
|
|
|
56
56
|
const VALID_RUNTIME = new Set(['container', 'host', 'mixed']);
|
|
57
57
|
const VALID_ACTIONS = new Set(['up', 'down', 'status', 'health', 'logs']);
|
|
58
58
|
const CONTAINER_EXTENSION_ROOT = '/app/extensions';
|
|
59
|
+
const DEFAULT_FINGERPRINT_PROFILE = {
|
|
60
|
+
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36',
|
|
61
|
+
locale: 'zh-CN',
|
|
62
|
+
acceptLanguage: 'zh-CN,zh;q=0.9',
|
|
63
|
+
timezoneId: 'Asia/Shanghai',
|
|
64
|
+
width: 1366,
|
|
65
|
+
height: 768
|
|
66
|
+
};
|
|
59
67
|
|
|
60
68
|
function sleep(ms) {
|
|
61
69
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
@@ -510,13 +518,21 @@ class PlaywrightPlugin {
|
|
|
510
518
|
const def = SCENE_DEFS[sceneName];
|
|
511
519
|
const port = this.scenePort(sceneName);
|
|
512
520
|
const extensionPaths = asStringArray(options.extensionPaths, []);
|
|
521
|
+
const baseLaunchArgs = [
|
|
522
|
+
`--user-agent=${DEFAULT_FINGERPRINT_PROFILE.userAgent}`,
|
|
523
|
+
`--lang=${DEFAULT_FINGERPRINT_PROFILE.locale}`,
|
|
524
|
+
`--window-size=${DEFAULT_FINGERPRINT_PROFILE.width},${DEFAULT_FINGERPRINT_PROFILE.height}`,
|
|
525
|
+
'--disable-blink-features=AutomationControlled',
|
|
526
|
+
'--force-webrtc-ip-handling-policy=disable_non_proxied_udp'
|
|
527
|
+
];
|
|
513
528
|
const launchOptions = {
|
|
514
529
|
channel: 'chromium',
|
|
515
|
-
headless: def.headless
|
|
530
|
+
headless: def.headless,
|
|
531
|
+
args: [...baseLaunchArgs]
|
|
516
532
|
};
|
|
517
533
|
|
|
518
534
|
if (extensionPaths.length > 0) {
|
|
519
|
-
launchOptions.args
|
|
535
|
+
launchOptions.args.push(...this.buildExtensionLaunchArgs(extensionPaths));
|
|
520
536
|
}
|
|
521
537
|
|
|
522
538
|
return {
|
|
@@ -535,7 +551,20 @@ class PlaywrightPlugin {
|
|
|
535
551
|
browserName: 'chromium',
|
|
536
552
|
launchOptions,
|
|
537
553
|
contextOptions: {
|
|
538
|
-
userAgent:
|
|
554
|
+
userAgent: DEFAULT_FINGERPRINT_PROFILE.userAgent,
|
|
555
|
+
locale: DEFAULT_FINGERPRINT_PROFILE.locale,
|
|
556
|
+
timezoneId: DEFAULT_FINGERPRINT_PROFILE.timezoneId,
|
|
557
|
+
viewport: {
|
|
558
|
+
width: DEFAULT_FINGERPRINT_PROFILE.width,
|
|
559
|
+
height: DEFAULT_FINGERPRINT_PROFILE.height
|
|
560
|
+
},
|
|
561
|
+
screen: {
|
|
562
|
+
width: DEFAULT_FINGERPRINT_PROFILE.width,
|
|
563
|
+
height: DEFAULT_FINGERPRINT_PROFILE.height
|
|
564
|
+
},
|
|
565
|
+
extraHTTPHeaders: {
|
|
566
|
+
'Accept-Language': DEFAULT_FINGERPRINT_PROFILE.acceptLanguage
|
|
567
|
+
}
|
|
539
568
|
}
|
|
540
569
|
}
|
|
541
570
|
};
|