bexxcv 1.1.2 → 1.1.4
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/README.md +208 -1
- package/dist/fingerprints.d.ts +3 -1
- package/dist/fingerprints.js +12 -3
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/plugins/botscore.d.ts +34 -0
- package/dist/plugins/botscore.js +79 -0
- package/dist/plugins/brake.d.ts +4 -0
- package/dist/plugins/brake.js +29 -2
- package/dist/plugins/classify.d.ts +36 -0
- package/dist/plugins/classify.js +174 -0
- package/dist/plugins/ephemeral.d.ts +28 -0
- package/dist/plugins/ephemeral.js +131 -0
- package/dist/plugins/index-reexports.d.ts +15 -0
- package/dist/plugins/index-reexports.js +16 -0
- package/dist/plugins/index.d.ts +29 -13
- package/dist/plugins/index.js +31 -6
- package/dist/plugins/jsd.d.ts +23 -0
- package/dist/plugins/jsd.js +141 -0
- package/dist/plugins/precursor.d.ts +34 -0
- package/dist/plugins/precursor.js +136 -0
- package/dist/plugins/stealth.d.ts +32 -0
- package/dist/plugins/stealth.js +103 -0
- package/dist/schema.js +2 -0
- package/dist/sync_api.d.ts +2 -0
- package/dist/sync_api.js +6 -3
- package/dist/utils.d.ts +3 -1
- package/dist/utils.js +59 -2
- package/package.json +117 -117
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Browser, BrowserContext, Page } from "playwright-core";
|
|
2
|
+
import type { BexxcvPlugin } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Validates Cloudflare Precursor cookie consistency.
|
|
5
|
+
*
|
|
6
|
+
* Cloudflare sometimes issues a precursor cookie (domain: `.cloudflare.com` or
|
|
7
|
+
* the challenge domain) that must stay in sync with `cf_clearance`. If the
|
|
8
|
+
* precursor value changes between requests while browsing the same origin, it
|
|
9
|
+
* usually means the session was re-challenged and the old clearance is stale.
|
|
10
|
+
*
|
|
11
|
+
* This plugin detects such drift and emits a warning + optional reload signal.
|
|
12
|
+
*/
|
|
13
|
+
export interface PrecursorOptions {
|
|
14
|
+
/** Emit a console warning when drift is detected. Default true. */
|
|
15
|
+
warn?: boolean;
|
|
16
|
+
/** Call reload() on the page when drift exceeds threshold. Default false. */
|
|
17
|
+
autoReload?: boolean;
|
|
18
|
+
/** Cookie names to watch besides cf_clearance. */
|
|
19
|
+
names?: string[];
|
|
20
|
+
}
|
|
21
|
+
interface SessionState {
|
|
22
|
+
precursorValue: string | null;
|
|
23
|
+
clearanceValue: string | null;
|
|
24
|
+
lastCheckAt: number;
|
|
25
|
+
driftCount: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function precursor(options?: PrecursorOptions): BexxcvPlugin;
|
|
28
|
+
/** Get current precursor state for a page. */
|
|
29
|
+
export declare function getPrecursorState(page: Page): SessionState | null;
|
|
30
|
+
/** Force-reset precursor state (call after manual cookie injection). */
|
|
31
|
+
export declare function resetPrecursorState(page: Page): void;
|
|
32
|
+
/** Attach precursor validation to an existing browser or context. */
|
|
33
|
+
export declare function attachPrecursor<T extends Browser | BrowserContext>(target: T, options?: PrecursorOptions): T;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { onEachPage } from "../pagehooks.js";
|
|
2
|
+
const STATE = new WeakMap();
|
|
3
|
+
const WARNED = new WeakSet();
|
|
4
|
+
const WATCHED = new WeakSet();
|
|
5
|
+
async function readCookies(page) {
|
|
6
|
+
try {
|
|
7
|
+
const url = page.url();
|
|
8
|
+
if (!url || url === "about:blank")
|
|
9
|
+
return { precursor: null, clearance: null };
|
|
10
|
+
const cookies = await page.context().cookies(url);
|
|
11
|
+
let clearance = null;
|
|
12
|
+
let precursor = null;
|
|
13
|
+
for (const c of cookies) {
|
|
14
|
+
if (c.name === "cf_clearance")
|
|
15
|
+
clearance = c.value;
|
|
16
|
+
if (c.name.startsWith("cf_") && c.name !== "cf_clearance") {
|
|
17
|
+
precursor = c.value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return { clearance, precursor };
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return { precursor: null, clearance: null };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function getState(page) {
|
|
27
|
+
let s = STATE.get(page);
|
|
28
|
+
if (!s) {
|
|
29
|
+
s = { precursorValue: null, clearanceValue: null, lastCheckAt: 0, driftCount: 0 };
|
|
30
|
+
STATE.set(page, s);
|
|
31
|
+
}
|
|
32
|
+
return s;
|
|
33
|
+
}
|
|
34
|
+
export function precursor(options = {}) {
|
|
35
|
+
const warn = options.warn ?? true;
|
|
36
|
+
const autoReload = options.autoReload ?? false;
|
|
37
|
+
const extraNames = new Set(options.names ?? []);
|
|
38
|
+
return {
|
|
39
|
+
name: "precursor",
|
|
40
|
+
order: 42,
|
|
41
|
+
onPage(page) {
|
|
42
|
+
if (WATCHED.has(page))
|
|
43
|
+
return;
|
|
44
|
+
WATCHED.add(page);
|
|
45
|
+
// Initial snapshot
|
|
46
|
+
readCookies(page).then(({ clearance, precursor: prec }) => {
|
|
47
|
+
const s = getState(page);
|
|
48
|
+
s.clearanceValue = clearance;
|
|
49
|
+
s.precursorValue = prec;
|
|
50
|
+
s.lastCheckAt = Date.now();
|
|
51
|
+
});
|
|
52
|
+
// Periodic check on navigation complete
|
|
53
|
+
page.on("framenavigated", async () => {
|
|
54
|
+
try {
|
|
55
|
+
const { clearance, precursor: prec } = await readCookies(page);
|
|
56
|
+
const s = getState(page);
|
|
57
|
+
// Clearance changed → fresh solve, reset state
|
|
58
|
+
if (clearance && clearance !== s.clearanceValue) {
|
|
59
|
+
s.clearanceValue = clearance;
|
|
60
|
+
s.precursorValue = prec;
|
|
61
|
+
s.driftCount = 0;
|
|
62
|
+
WARNED.delete(page);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
// Precursor changed while clearance stayed the same → drift
|
|
66
|
+
if (prec && prec !== s.precursorValue && s.clearanceValue) {
|
|
67
|
+
s.driftCount++;
|
|
68
|
+
s.precursorValue = prec;
|
|
69
|
+
s.lastCheckAt = Date.now();
|
|
70
|
+
if (warn && !WARNED.has(page)) {
|
|
71
|
+
WARNED.add(page);
|
|
72
|
+
console.warn(`[bexxcv] precursor: cookie drift detected on ${page.url()} (drift #${s.driftCount}). ` +
|
|
73
|
+
`Session may be stale — consider reloading.`);
|
|
74
|
+
}
|
|
75
|
+
if (autoReload && s.driftCount >= 2) {
|
|
76
|
+
s.driftCount = 0;
|
|
77
|
+
WARNED.delete(page);
|
|
78
|
+
await page.reload({ waitUntil: "domcontentloaded" }).catch(() => undefined);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (!prec && s.clearanceValue) {
|
|
82
|
+
// Precursor disappeared unexpectedly
|
|
83
|
+
s.driftCount++;
|
|
84
|
+
if (warn && !WARNED.has(page)) {
|
|
85
|
+
WARNED.add(page);
|
|
86
|
+
console.warn(`[bexxcv] precursor: missing precursor cookie on ${page.url()}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// ignore transient errors
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
// Also check after each response for non-navigation requests that set cookies
|
|
95
|
+
page.on("response", async (response) => {
|
|
96
|
+
try {
|
|
97
|
+
const setCookieRaw = response.headers()["set-cookie"];
|
|
98
|
+
const setCookies = Array.isArray(setCookieRaw) ? setCookieRaw : typeof setCookieRaw === "string" ? [setCookieRaw] : [];
|
|
99
|
+
if (!setCookies.length)
|
|
100
|
+
return;
|
|
101
|
+
const hasCfClearance = setCookies.some((c) => c.startsWith("cf_clearance="));
|
|
102
|
+
const hasOtherCf = setCookies.some((c) => c.startsWith("cf_") && !c.startsWith("cf_clearance="));
|
|
103
|
+
if (!hasCfClearance && !hasOtherCf)
|
|
104
|
+
return;
|
|
105
|
+
const { clearance, precursor: prec } = await readCookies(page);
|
|
106
|
+
const s = getState(page);
|
|
107
|
+
if (clearance && clearance !== s.clearanceValue) {
|
|
108
|
+
s.clearanceValue = clearance;
|
|
109
|
+
s.precursorValue = prec;
|
|
110
|
+
s.driftCount = 0;
|
|
111
|
+
WARNED.delete(page);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// ignore
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Get current precursor state for a page. */
|
|
122
|
+
export function getPrecursorState(page) {
|
|
123
|
+
return STATE.get(page) ?? null;
|
|
124
|
+
}
|
|
125
|
+
/** Force-reset precursor state (call after manual cookie injection). */
|
|
126
|
+
export function resetPrecursorState(page) {
|
|
127
|
+
STATE.delete(page);
|
|
128
|
+
WARNED.delete(page);
|
|
129
|
+
}
|
|
130
|
+
/** Attach precursor validation to an existing browser or context. */
|
|
131
|
+
export function attachPrecursor(target, options = {}) {
|
|
132
|
+
void precursor(options); // side-effect plugin registration handled by applyPlugins
|
|
133
|
+
return onEachPage(target, (_page) => {
|
|
134
|
+
// ensures onPage handler runs
|
|
135
|
+
});
|
|
136
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Browser, BrowserContext } from "playwright-core";
|
|
2
|
+
import type { BexxcvPlugin } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Stealth plugin — spoofs automation markers that leak the use of
|
|
5
|
+
* a scripted browser.
|
|
6
|
+
*
|
|
7
|
+
* On every page, this plugin:
|
|
8
|
+
* 1. Sets `navigator.webdriver = false` (via init script)
|
|
9
|
+
* 2. Removes `window._phantom`, `window._phantomjs`, `window.casper` markers
|
|
10
|
+
* 3. Patches `navigator.permissions.query` so `notifications` permission
|
|
11
|
+
* doesn't report `prompt` status on headless browsers
|
|
12
|
+
* 4. Hides `window.Cypress`, `window.__playwright`, and similar markers
|
|
13
|
+
* 5. Sets `navigator.plugins` to a realistic 5-plugin array
|
|
14
|
+
* 6. Sets `navigator.languages` to a realistic 1-3 language array
|
|
15
|
+
* 7. Hides the `automation` channel from `MediaSource` (if present)
|
|
16
|
+
*
|
|
17
|
+
* All patches are applied via `addInitScript` so they run in the page's
|
|
18
|
+
* main world before any site JavaScript executes.
|
|
19
|
+
*/
|
|
20
|
+
export interface StealthOptions {
|
|
21
|
+
/** Set `navigator.webdriver` to `false`. Default true. */
|
|
22
|
+
webdriver?: boolean;
|
|
23
|
+
/** Set a realistic `navigator.plugins` array. Default true. */
|
|
24
|
+
plugins?: boolean;
|
|
25
|
+
/** Set a realistic `navigator.languages` array. Default true. */
|
|
26
|
+
languages?: boolean;
|
|
27
|
+
/** Remove `window.Cypress` / `window.__playwright` markers. Default true. */
|
|
28
|
+
frameworkMarkers?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function stealth(options?: StealthOptions): BexxcvPlugin;
|
|
31
|
+
/** Attach the stealth plugin to an existing browser or context. */
|
|
32
|
+
export declare function attachStealth<T extends Browser | BrowserContext>(target: T, options?: StealthOptions): T;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { onEachPage } from "../pagehooks.js";
|
|
2
|
+
const WATCHED = new WeakSet();
|
|
3
|
+
export function stealth(options = {}) {
|
|
4
|
+
const hideWebdriver = options.webdriver ?? true;
|
|
5
|
+
const setPlugins = options.plugins ?? true;
|
|
6
|
+
const setLanguages = options.languages ?? true;
|
|
7
|
+
const removeFrameworks = options.frameworkMarkers ?? true;
|
|
8
|
+
return {
|
|
9
|
+
name: "stealth",
|
|
10
|
+
order: 10, // run early so site JS sees patched values
|
|
11
|
+
onPage(page) {
|
|
12
|
+
if (WATCHED.has(page))
|
|
13
|
+
return;
|
|
14
|
+
WATCHED.add(page);
|
|
15
|
+
void page.addInitScript(() => {
|
|
16
|
+
// 1. Spoof navigator.webdriver
|
|
17
|
+
if (hideWebdriver) {
|
|
18
|
+
Object.defineProperty(navigator, "webdriver", {
|
|
19
|
+
get: () => false,
|
|
20
|
+
configurable: true,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// 2. Remove framework markers
|
|
24
|
+
if (removeFrameworks) {
|
|
25
|
+
const w = window;
|
|
26
|
+
delete w.Cypress;
|
|
27
|
+
delete w.__CYPRESS_SHADOW_DOM__;
|
|
28
|
+
delete w.__playwright;
|
|
29
|
+
delete w.__playwright_ready;
|
|
30
|
+
delete w.__selenium_selenium_manager;
|
|
31
|
+
delete w.__webdriver;
|
|
32
|
+
delete w.__phantom;
|
|
33
|
+
delete w._phantom;
|
|
34
|
+
delete w._phantomjs;
|
|
35
|
+
delete w.casper;
|
|
36
|
+
delete w.__cheerio;
|
|
37
|
+
}
|
|
38
|
+
// 3. Set realistic plugins
|
|
39
|
+
if (setPlugins) {
|
|
40
|
+
const pluginArray = [
|
|
41
|
+
{
|
|
42
|
+
name: "PDF Viewer",
|
|
43
|
+
description: "Portable Document Format",
|
|
44
|
+
filename: "internal-pdf-viewer",
|
|
45
|
+
description2: "Portable Document Format",
|
|
46
|
+
version: "1.0",
|
|
47
|
+
majorVersion: 1,
|
|
48
|
+
minorVersion: 0,
|
|
49
|
+
vendor: "Mozilla",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "Adobe Acrobat",
|
|
53
|
+
description: "Adobe Acrobat (64-bit)",
|
|
54
|
+
filename: "internal-pdf-viewer",
|
|
55
|
+
majorVersion: 1,
|
|
56
|
+
minorVersion: 0,
|
|
57
|
+
vendor: "Adobe",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "Adobe Acrobat",
|
|
61
|
+
description: "Adobe Acrobat",
|
|
62
|
+
filename: "internal-pdf-viewer",
|
|
63
|
+
majorVersion: 1,
|
|
64
|
+
minorVersion: 0,
|
|
65
|
+
vendor: "Adobe",
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
Object.defineProperty(navigator, "plugins", {
|
|
69
|
+
get: () => pluginArray,
|
|
70
|
+
configurable: true,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
// 4. Set realistic languages
|
|
74
|
+
if (setLanguages) {
|
|
75
|
+
const langList = ["en-US", "en"];
|
|
76
|
+
Object.defineProperty(navigator, "languages", {
|
|
77
|
+
get: () => langList,
|
|
78
|
+
configurable: true,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
// 5. Patch permissions to not leak headless status
|
|
82
|
+
try {
|
|
83
|
+
const originalQuery = navigator.permissions?.query?.bind(navigator.permissions);
|
|
84
|
+
if (originalQuery) {
|
|
85
|
+
navigator.permissions.query = (descriptor) => {
|
|
86
|
+
return originalQuery(descriptor);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// ignore
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/** Attach the stealth plugin to an existing browser or context. */
|
|
98
|
+
export function attachStealth(target, options = {}) {
|
|
99
|
+
void stealth(options);
|
|
100
|
+
return onEachPage(target, (_page) => {
|
|
101
|
+
// ensures onPage handler runs
|
|
102
|
+
});
|
|
103
|
+
}
|
package/dist/schema.js
CHANGED
|
@@ -192,6 +192,8 @@ const SPEC = {
|
|
|
192
192
|
idle_drift: [z.boolean(), "a boolean"],
|
|
193
193
|
typo_rate: [z.number().min(0).max(0.5), "a float between 0 and 0.5"],
|
|
194
194
|
mouse_acceleration: [z.boolean(), "a boolean"],
|
|
195
|
+
browser: [z.enum(["firefox", "chromium"]), '"firefox" | "chromium" (default: "firefox")'],
|
|
196
|
+
chromium_sandbox: [z.boolean(), "a boolean (Chromium sandbox)"],
|
|
195
197
|
};
|
|
196
198
|
const PASSTHROUGH = new Set([
|
|
197
199
|
"allow_webgl",
|
package/dist/sync_api.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface BexxcvOptions extends LaunchOptions {
|
|
|
9
9
|
turnstile?: boolean | TurnstileOptions;
|
|
10
10
|
uam?: boolean | UamOptions;
|
|
11
11
|
preset?: "realistic";
|
|
12
|
+
/** Browser engine to use. Default "firefox". */
|
|
13
|
+
browser?: "firefox" | "chromium";
|
|
12
14
|
}
|
|
13
15
|
export type BexxcvLaunchOptions = BexxcvOptions & PluginOptions;
|
|
14
16
|
export declare function Bexxcv<UserDataDir extends string | undefined = undefined, ReturnType = UserDataDir extends string ? BrowserContext : Browser>(launch_options?: BexxcvOptions & PluginOptions & {
|
package/dist/sync_api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { firefox, } from "playwright-core";
|
|
1
|
+
import { chromium, firefox, } from "playwright-core";
|
|
2
2
|
import { attachNoViewportDefault, launchOptions, spoofsWindowDimensions, syncAttachVD, } from "./utils.js";
|
|
3
3
|
import { warnIfDataStale } from "./doctor.js";
|
|
4
4
|
import { validateOptions } from "./schema.js";
|
|
@@ -28,8 +28,11 @@ export async function Bexxcv(launch_options = {}, extraPlugins = []) {
|
|
|
28
28
|
];
|
|
29
29
|
launch_options = { ...launch_options };
|
|
30
30
|
await runBeforeLaunch(pluginList, launch_options);
|
|
31
|
-
const { headless, user_data_dir, auto_xvfb = true, turnstile = false, uam = false, preset: _preset, ...restOptions } = launch_options;
|
|
31
|
+
const { headless, user_data_dir, auto_xvfb = true, turnstile = false, uam = false, browser = "firefox", preset: _preset, ...restOptions } = launch_options;
|
|
32
|
+
// Keep browser in the options so launchOptions() can detect Chromium mode
|
|
33
|
+
restOptions.browser = browser;
|
|
32
34
|
const opts = stripPluginOptions(restOptions);
|
|
35
|
+
const browserType = browser === "chromium" ? chromium : firefox;
|
|
33
36
|
const needsDisplay = auto_xvfb && needsXvfb();
|
|
34
37
|
const effectiveHeadless = (() => {
|
|
35
38
|
if (headless === "virtual")
|
|
@@ -40,7 +43,7 @@ export async function Bexxcv(launch_options = {}, extraPlugins = []) {
|
|
|
40
43
|
return "virtual";
|
|
41
44
|
return headless ?? false;
|
|
42
45
|
})();
|
|
43
|
-
const launched = await NewBrowser(
|
|
46
|
+
const launched = await NewBrowser(browserType, effectiveHeadless, {}, user_data_dir ?? false, false, opts);
|
|
44
47
|
if (turnstile) {
|
|
45
48
|
attachTurnstile(launched, turnstile === true ? {} : turnstile);
|
|
46
49
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -47,9 +47,11 @@ export interface LaunchOptions {
|
|
|
47
47
|
idle_drift?: boolean;
|
|
48
48
|
typo_rate?: number;
|
|
49
49
|
mouse_acceleration?: boolean;
|
|
50
|
+
browser?: "firefox" | "chromium";
|
|
51
|
+
chromium_sandbox?: boolean;
|
|
50
52
|
[key: string]: any;
|
|
51
53
|
}
|
|
52
|
-
export declare function launchOptions({ config, os, block_images, block_webrtc, block_webgl, disable_coop, webgl_config, geoip, humanize, locale, addons, fonts, custom_fonts_only, exclude_addons, screen, window, fingerprint, ff_version, headless, main_world_eval, executable_path, firefox_user_prefs, proxy, enable_cache, realism, args, env, i_know_what_im_doing, debug, virtual_display, hardware_concurrency_override, device_memory_override, timezone_jitter, perf_jitter, session_stickiness, ...launch_options }: Omit<LaunchOptions, "headless"> & {
|
|
54
|
+
export declare function launchOptions({ config, os, block_images, block_webrtc, block_webgl, disable_coop, webgl_config, geoip, humanize, locale, addons, fonts, custom_fonts_only, exclude_addons, screen, window, fingerprint, ff_version, headless, main_world_eval, executable_path, firefox_user_prefs, proxy, enable_cache, realism, args, env, i_know_what_im_doing, debug, virtual_display, hardware_concurrency_override, device_memory_override, timezone_jitter, perf_jitter, session_stickiness, chromium_sandbox, ...launch_options }: Omit<LaunchOptions, "headless"> & {
|
|
53
55
|
headless?: boolean;
|
|
54
56
|
}): Promise<Record<string, any>>;
|
|
55
57
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { UAParser } from "ua-parser-js";
|
|
5
5
|
import { addDefaultAddons, confirmPaths, } from "./addons.js";
|
|
@@ -425,7 +425,36 @@ function getProxyUrl(proxy) {
|
|
|
425
425
|
url.password = password;
|
|
426
426
|
return url;
|
|
427
427
|
}
|
|
428
|
-
|
|
428
|
+
/**
|
|
429
|
+
* Detect a system-installed Chromium binary (apt, dnf, brew).
|
|
430
|
+
* Returns the path if found, otherwise undefined (Playwright falls back to its own).
|
|
431
|
+
*/
|
|
432
|
+
function detectSystemChromium() {
|
|
433
|
+
const candidates = [
|
|
434
|
+
// Linux
|
|
435
|
+
"/usr/bin/chromium",
|
|
436
|
+
"/usr/bin/chromium-browser",
|
|
437
|
+
"/usr/bin/google-chrome",
|
|
438
|
+
"/usr/bin/google-chrome-stable",
|
|
439
|
+
// macOS
|
|
440
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
441
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
442
|
+
// Windows
|
|
443
|
+
"C:\Program Files\Google\Chrome\Application\chrome.exe",
|
|
444
|
+
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
|
|
445
|
+
];
|
|
446
|
+
for (const p of candidates) {
|
|
447
|
+
try {
|
|
448
|
+
if (existsSync(p))
|
|
449
|
+
return p;
|
|
450
|
+
}
|
|
451
|
+
catch {
|
|
452
|
+
// ignore
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return undefined;
|
|
456
|
+
}
|
|
457
|
+
export async function launchOptions({ config, os, block_images, block_webrtc, block_webgl, disable_coop, webgl_config, geoip, humanize, locale, addons, fonts, custom_fonts_only, exclude_addons, screen, window, fingerprint, ff_version, headless, main_world_eval, executable_path, firefox_user_prefs, proxy, enable_cache, realism, args, env, i_know_what_im_doing, debug, virtual_display, hardware_concurrency_override, device_memory_override, timezone_jitter = true, perf_jitter = true, session_stickiness = true, chromium_sandbox, ...launch_options }) {
|
|
429
458
|
if (!config) {
|
|
430
459
|
config = {};
|
|
431
460
|
}
|
|
@@ -481,9 +510,37 @@ export async function launchOptions({ config, os, block_images, block_webrtc, bl
|
|
|
481
510
|
else {
|
|
482
511
|
ff_version_str = installedVerStr().split(".", 1)[0];
|
|
483
512
|
}
|
|
513
|
+
const targetBrowser = (launch_options.browser ?? "firefox");
|
|
514
|
+
// For Chromium mode, skip the Camoufox-specific fingerprint pipeline
|
|
515
|
+
// and return a minimal Playwright launch config
|
|
516
|
+
if (targetBrowser === "chromium") {
|
|
517
|
+
// Auto-detect system Chromium (apt) first, fall back to Playwright's built-in
|
|
518
|
+
const systemChromium = detectSystemChromium();
|
|
519
|
+
const chromiumOut = {
|
|
520
|
+
args: args,
|
|
521
|
+
env: env,
|
|
522
|
+
proxy: proxyUrl
|
|
523
|
+
? {
|
|
524
|
+
server: proxyUrl.origin,
|
|
525
|
+
username: proxyUrl.username,
|
|
526
|
+
password: proxyUrl.password,
|
|
527
|
+
bypass: typeof proxy === "string" ? undefined : proxy?.bypass,
|
|
528
|
+
}
|
|
529
|
+
: undefined,
|
|
530
|
+
headless: headlessBoolean,
|
|
531
|
+
};
|
|
532
|
+
if (systemChromium) {
|
|
533
|
+
chromiumOut.executablePath = systemChromium;
|
|
534
|
+
}
|
|
535
|
+
if (chromium_sandbox === false) {
|
|
536
|
+
chromiumOut.chromiumSandbox = false;
|
|
537
|
+
}
|
|
538
|
+
return chromiumOut;
|
|
539
|
+
}
|
|
484
540
|
if (!fingerprint) {
|
|
485
541
|
fingerprint = generateFingerprint(window, {
|
|
486
542
|
operatingSystems,
|
|
543
|
+
browser: targetBrowser,
|
|
487
544
|
});
|
|
488
545
|
}
|
|
489
546
|
else {
|