bexxcv 1.1.3 → 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 -7
- package/dist/fingerprints.js +36 -58
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/index-reexports.d.ts +1 -0
- package/dist/plugins/index-reexports.js +1 -0
- package/dist/plugins/index.d.ts +8 -5
- package/dist/plugins/index.js +5 -1
- package/dist/plugins/jsd.js +8 -1
- 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/dist/webgl/profiles.d.ts +0 -4
- package/dist/webgl/profiles.js +118 -168
- package/package.json +117 -117
|
@@ -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 {
|
package/dist/webgl/profiles.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Level-max GPU profiles — expanded with 2024–2026 hardware, tighter weight distributions,
|
|
3
|
-
* and OS-specific renderer naming conventions that match real driver strings.
|
|
4
|
-
*/
|
|
5
1
|
export declare const KNOWN_GPUS: Record<"win" | "mac" | "lin", Array<{
|
|
6
2
|
vendor: string;
|
|
7
3
|
renderer: string;
|
package/dist/webgl/profiles.js
CHANGED
|
@@ -1,92 +1,65 @@
|
|
|
1
1
|
import { UAParser } from "ua-parser-js";
|
|
2
|
-
/**
|
|
3
|
-
* Level-max GPU profiles — expanded with 2024–2026 hardware, tighter weight distributions,
|
|
4
|
-
* and OS-specific renderer naming conventions that match real driver strings.
|
|
5
|
-
*/
|
|
6
2
|
export const KNOWN_GPUS = {
|
|
7
3
|
win: [
|
|
8
|
-
//
|
|
9
|
-
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 630", weight:
|
|
10
|
-
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 620", weight:
|
|
11
|
-
{ vendor: "Intel", renderer: "Intel(R) Iris
|
|
12
|
-
{ vendor: "Intel", renderer: "Intel(R) HD Graphics
|
|
13
|
-
{ vendor: "Intel", renderer: "Intel(R)
|
|
14
|
-
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{ vendor: "
|
|
18
|
-
{ vendor: "
|
|
19
|
-
{ vendor: "
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{ vendor: "
|
|
23
|
-
{ vendor: "
|
|
24
|
-
{ vendor: "
|
|
25
|
-
|
|
26
|
-
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 4060", weight: 4 },
|
|
27
|
-
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 4060 Ti", weight: 3 },
|
|
28
|
-
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 4070", weight: 2 },
|
|
29
|
-
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 2060", weight: 3 },
|
|
30
|
-
// ── AMD discrete ───────────────────────────────────────────────────────
|
|
31
|
-
{ vendor: "AMD", renderer: "AMD Radeon RX 6600", weight: 5 },
|
|
32
|
-
{ vendor: "AMD", renderer: "AMD Radeon RX 580 Series", weight: 3 },
|
|
33
|
-
{ vendor: "AMD", renderer: "AMD Radeon RX 7800 XT", weight: 3 },
|
|
34
|
-
{ vendor: "AMD", renderer: "AMD Radeon RX 7600", weight: 2 },
|
|
35
|
-
{ vendor: "AMD", renderer: "AMD Radeon RX 6700 XT", weight: 2 },
|
|
36
|
-
// ── VM / virtualised fallback ──────────────────────────────────────────
|
|
4
|
+
// Intel integrated — most common on office/home PCs
|
|
5
|
+
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 630", weight: 28 },
|
|
6
|
+
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 620", weight: 18 },
|
|
7
|
+
{ vendor: "Intel", renderer: "Intel(R) Iris Xe Graphics", weight: 14 },
|
|
8
|
+
{ vendor: "Intel", renderer: "Intel(R) HD Graphics 620", weight: 8 },
|
|
9
|
+
{ vendor: "Intel", renderer: "Intel(R) HD Graphics 530", weight: 5 },
|
|
10
|
+
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 730", weight: 3 },
|
|
11
|
+
// NVIDIA discrete — gaming/workstations
|
|
12
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce GTX 1650", weight: 10 },
|
|
13
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce GTX 1050 Ti", weight: 7 },
|
|
14
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 3060", weight: 5 },
|
|
15
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 3060 Ti", weight: 3 },
|
|
16
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 4060", weight: 2 },
|
|
17
|
+
// AMD discrete
|
|
18
|
+
{ vendor: "AMD", renderer: "AMD Radeon RX 6600", weight: 4 },
|
|
19
|
+
{ vendor: "AMD", renderer: "AMD Radeon RX 580", weight: 3 },
|
|
20
|
+
{ vendor: "AMD", renderer: "AMD Radeon RX 7800 XT", weight: 2 },
|
|
21
|
+
// Microsoft basic — VM fallback
|
|
37
22
|
{ vendor: "Microsoft", renderer: "Microsoft Basic Render Driver", weight: 2 },
|
|
38
23
|
],
|
|
39
24
|
mac: [
|
|
40
|
-
//
|
|
41
|
-
{ vendor: "Apple", renderer: "Apple
|
|
42
|
-
{ vendor: "Apple", renderer: "Apple
|
|
43
|
-
{ vendor: "Apple", renderer: "Apple
|
|
44
|
-
{ vendor: "Apple", renderer: "Apple
|
|
45
|
-
{ vendor: "Apple", renderer: "Apple
|
|
46
|
-
{ vendor: "Apple", renderer: "Apple M3
|
|
47
|
-
{ vendor: "Apple", renderer: "Apple
|
|
48
|
-
{ vendor: "Apple", renderer: "Apple
|
|
49
|
-
{ vendor: "Apple", renderer: "Apple
|
|
50
|
-
|
|
51
|
-
{ vendor: "Apple", renderer: "Apple
|
|
52
|
-
{ vendor: "Apple", renderer: "Apple
|
|
53
|
-
// ── Intel Macs (legacy enterprise still present) ─────────────────────
|
|
54
|
-
{ vendor: "Apple", renderer: "Apple Integrated GPU", weight: 3 },
|
|
55
|
-
{ vendor: "Apple", renderer: "Apple MacBook Pro GPU", weight: 1 },
|
|
25
|
+
// Apple Silicon
|
|
26
|
+
{ vendor: "Apple", renderer: "Apple M1", weight: 22 },
|
|
27
|
+
{ vendor: "Apple", renderer: "Apple M1 Pro", weight: 14 },
|
|
28
|
+
{ vendor: "Apple", renderer: "Apple M1 Max", weight: 8 },
|
|
29
|
+
{ vendor: "Apple", renderer: "Apple M2", weight: 18 },
|
|
30
|
+
{ vendor: "Apple", renderer: "Apple M2 Pro", weight: 10 },
|
|
31
|
+
{ vendor: "Apple", renderer: "Apple M3", weight: 8 },
|
|
32
|
+
{ vendor: "Apple", renderer: "Apple M3 Pro", weight: 6 },
|
|
33
|
+
{ vendor: "Apple", renderer: "Apple M4", weight: 4 },
|
|
34
|
+
{ vendor: "Apple", renderer: "Apple M4 Pro", weight: 3 },
|
|
35
|
+
// Intel Macs (still common in enterprise)
|
|
36
|
+
{ vendor: "Apple", renderer: "Apple Integrated GPU", weight: 5 },
|
|
37
|
+
{ vendor: "Apple", renderer: "Apple MacBook Pro GPU", weight: 2 },
|
|
56
38
|
],
|
|
57
39
|
lin: [
|
|
58
|
-
//
|
|
59
|
-
{ vendor: "Intel", renderer: "Intel(R) HD Graphics 630 (KBL GT2)", weight:
|
|
40
|
+
// Intel on Linux desktops
|
|
41
|
+
{ vendor: "Intel", renderer: "Intel(R) HD Graphics 630 (KBL GT2)", weight: 18 },
|
|
60
42
|
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 630 (CFL GT2)", weight: 10 },
|
|
61
43
|
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 770 (ADL GT2)", weight: 7 },
|
|
62
|
-
{ vendor: "Intel", renderer: "Mesa Intel(R) UHD Graphics 620 (KBL GT2)", weight:
|
|
44
|
+
{ vendor: "Intel", renderer: "Mesa Intel(R) UHD Graphics 620 (KBL GT2)", weight: 6 },
|
|
63
45
|
{ vendor: "Intel", renderer: "Mesa Intel(R) UHD Graphics 630 (KBL GT2)", weight: 4 },
|
|
64
|
-
//
|
|
65
|
-
{ vendor: "
|
|
66
|
-
|
|
67
|
-
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX
|
|
68
|
-
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce
|
|
69
|
-
|
|
70
|
-
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 4060/PCIe/SSE2", weight: 3 },
|
|
71
|
-
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce GTX 1650/PCIe/SSE2", weight: 4 },
|
|
72
|
-
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 3060 Ti/PCIe/SSE2", weight: 3 },
|
|
73
|
-
// ── AMD discrete ─────────────────────────────────────────────────────
|
|
46
|
+
// NVIDIA on Linux
|
|
47
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 3080", weight: 8 },
|
|
48
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 3060", weight: 6 },
|
|
49
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 4090", weight: 3 },
|
|
50
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce GTX 1650", weight: 4 },
|
|
51
|
+
// AMD on Linux
|
|
74
52
|
{ vendor: "AMD", renderer: "AMD Radeon RX 6600 (RADV NAVI23)", weight: 5 },
|
|
75
53
|
{ vendor: "AMD", renderer: "AMD Radeon RX 7800 XT (RADV NAVI32)", weight: 4 },
|
|
76
54
|
{ vendor: "AMD", renderer: "AMD Radeon Graphics (RADV NAVI21)", weight: 5 },
|
|
77
55
|
{ vendor: "AMD", renderer: "AMD Radeon RX 7900 XTX (RADV NAVI31)", weight: 3 },
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{ vendor: "llvmpipe", renderer: "llvmpipe (LLVM
|
|
81
|
-
{ vendor: "
|
|
82
|
-
{ vendor: "llvmpipe", renderer: "llvmpipe (LLVM 15.0.7, 256 bits)", weight: 3 },
|
|
83
|
-
// ── ANGLE (Chromium-based renderers inside Firefox on Linux) ─────────
|
|
84
|
-
{ vendor: "Google Inc.", renderer: "ANGLE (Intel, Intel(R) UHD Graphics 630, OpenGL 4.6)", weight: 4 },
|
|
85
|
-
// ── WebRender (Firefox native) ───────────────────────────────────────
|
|
56
|
+
// Software renderers (VMs, CI servers)
|
|
57
|
+
{ vendor: "llvmpipe", renderer: "llvmpipe (LLVM 15.0.7 256 bits)", weight: 8 },
|
|
58
|
+
{ vendor: "llvmpipe", renderer: "llvmpipe (LLVM 16.0.6 256 bits)", weight: 4 },
|
|
59
|
+
{ vendor: "Google Inc.", renderer: "ANGLE (Intel, Intel(R) UHD Graphics 630, OpenGL 4.6)", weight: 5 },
|
|
86
60
|
{ vendor: "Mozilla", renderer: "WebRender (NVIDIA Corporation -- 4.6 (Compatibility))", weight: 3 },
|
|
87
61
|
],
|
|
88
62
|
};
|
|
89
|
-
// ── WebGL extension pools ──────────────────────────────────────────────────────
|
|
90
63
|
const BASE_WEBGL_EXTENSIONS = [
|
|
91
64
|
"WEBGL_lose_context",
|
|
92
65
|
"WEBGL_compressed_texture_s3tc",
|
|
@@ -104,103 +77,98 @@ const BASE_WEBGL_EXTENSIONS = [
|
|
|
104
77
|
"EXT_texture_compression_rgtc",
|
|
105
78
|
"EXT_texture_filter_anisotropic",
|
|
106
79
|
"KHR_parallel_shader_compile",
|
|
107
|
-
];
|
|
108
|
-
const OPTIONAL_EXTENSIONS_WIN = [
|
|
109
|
-
"WEBGL_sample_variables",
|
|
110
|
-
"EXT_color_buffer_float",
|
|
111
|
-
"WEBGL_clip_cull_distance",
|
|
112
|
-
"EXT_disjoint_timer_query",
|
|
113
|
-
"WEBGL_multisampled_render_to_texture",
|
|
114
|
-
"EXT_texture_compression_rgtc",
|
|
115
|
-
"ANGLE_instanced_arrays",
|
|
116
80
|
"OES_element_index_uint",
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
"EXT_color_buffer_float",
|
|
122
|
-
"WEBGL_clip_cull_distance",
|
|
123
|
-
"EXT_disjoint_timer_query",
|
|
124
|
-
"WEBGL_multisampled_render_to_texture",
|
|
125
|
-
"APPLE_rgba_float",
|
|
126
|
-
"GL_EXT_blend_minmax",
|
|
127
|
-
"ANGLE_instanced_arrays",
|
|
81
|
+
"OES_standard_derivatives",
|
|
82
|
+
"OES_vertex_array_object",
|
|
83
|
+
"WEBGL_color_buffer_float",
|
|
84
|
+
"WEBGL_provoking_vertex",
|
|
128
85
|
];
|
|
86
|
+
// Optional extensions that some GPUs/drivers support
|
|
87
|
+
const OPTIONAL_EXTENSIONS_WIN = ["WEBGL_sample_variables", "EXT_color_buffer_float"];
|
|
88
|
+
const OPTIONAL_EXTENSIONS_MAC = ["WEBGL_sample_variables", "EXT_color_buffer_float"];
|
|
129
89
|
const OPTIONAL_EXTENSIONS_LIN = [
|
|
130
90
|
"WEBGL_sample_variables",
|
|
131
91
|
"EXT_color_buffer_float",
|
|
132
|
-
"
|
|
133
|
-
"EXT_disjoint_timer_query",
|
|
134
|
-
"WEBGL_multisampled_render_to_texture",
|
|
92
|
+
"WEBGL_polygon_mode",
|
|
135
93
|
"EXT_shader_texture_lod",
|
|
136
|
-
"
|
|
137
|
-
"_ANGLE_instanced_arrays",
|
|
138
|
-
"NV_conditional_render",
|
|
139
|
-
"EXT_robustness",
|
|
94
|
+
"WEBGL_clip_cull_distance",
|
|
140
95
|
];
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
"OpenGL GLSL 4.60",
|
|
154
|
-
],
|
|
155
|
-
AMD: [
|
|
156
|
-
"OpenGL GLSL 4.60",
|
|
157
|
-
"OpenGL ES GLSL 3.00 (Builder ID:808)",
|
|
158
|
-
"OpenGL GLSL 4.50 AMD",
|
|
159
|
-
"OpenGL GLSL 4.60 (allocator : Amdllp)",
|
|
160
|
-
],
|
|
161
|
-
Mesa: [
|
|
162
|
-
"OpenGL GLSL 4.60 (adapter: Mesa; driver: ",
|
|
163
|
-
"OpenGL ES GLSL 3.00 (Mesa 24.0.2-1.kali2)",
|
|
164
|
-
"OpenGL GLSL 4.50 (Mesa 23.2.1-1debian)",
|
|
165
|
-
"OpenGL ES GLSL 3.00 (Mesa 23.2.1-1debian)",
|
|
166
|
-
],
|
|
167
|
-
Apple: [
|
|
168
|
-
"OpenGL GLSL 4.1",
|
|
169
|
-
"OpenGL ES GLSL 3.00",
|
|
170
|
-
"Metal API GLSL 1.2.0",
|
|
171
|
-
"Metal API GLSL 1.3.0",
|
|
172
|
-
],
|
|
173
|
-
llvmpipe: [
|
|
174
|
-
"OpenGL GLSL 4.50 (Mesa 23.2.1)",
|
|
175
|
-
"OpenGL ES GLSL 3.00 (llvmpipe LLVM 17.0.6)",
|
|
176
|
-
"OpenGL ES GLSL 3.00 (llvmpipe LLVM 16.0.6)",
|
|
177
|
-
],
|
|
178
|
-
Microsoft: ["OpenGL ES GLSL 1.0.0"],
|
|
179
|
-
Mozilla: ["OpenGL GLSL 4.60"],
|
|
180
|
-
"Google Inc.": ["OpenGL ES GLSL 3.00"],
|
|
181
|
-
};
|
|
182
|
-
// ── Public API ────────────────────────────────────────────────────────────────
|
|
96
|
+
function pickWeighted(items, weights) {
|
|
97
|
+
const total = weights.reduce((a, b) => a + b, 0);
|
|
98
|
+
const buf = new Uint32Array(1);
|
|
99
|
+
crypto.getRandomValues(buf);
|
|
100
|
+
let threshold = (buf[0] / 0x100000000) * total;
|
|
101
|
+
for (let i = 0; i < items.length; i++) {
|
|
102
|
+
threshold -= weights[i];
|
|
103
|
+
if (threshold <= 0)
|
|
104
|
+
return items[i];
|
|
105
|
+
}
|
|
106
|
+
return items[items.length - 1];
|
|
107
|
+
}
|
|
183
108
|
export function sampleGPUProfile(os) {
|
|
184
109
|
const pool = KNOWN_GPUS[os];
|
|
185
|
-
const
|
|
186
|
-
const vendorEntry = pool.find(
|
|
110
|
+
const gpu = pickWeighted(pool.map(g => g.renderer), pool.map(g => g.weight));
|
|
111
|
+
const vendorEntry = pool.find(g => g.renderer === gpu);
|
|
187
112
|
const vendor = vendorEntry.vendor;
|
|
188
|
-
// Build
|
|
113
|
+
// Build base extension list
|
|
189
114
|
const baseExts = [...BASE_WEBGL_EXTENSIONS];
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
115
|
+
// Add optional extensions probabilistically
|
|
116
|
+
const optionalPool = os === "win"
|
|
117
|
+
? OPTIONAL_EXTENSIONS_WIN
|
|
118
|
+
: os === "mac"
|
|
119
|
+
? OPTIONAL_EXTENSIONS_MAC
|
|
120
|
+
: OPTIONAL_EXTENSIONS_LIN;
|
|
121
|
+
const numOptional = cryptoRandInt(0, Math.min(2, optionalPool.length));
|
|
193
122
|
for (let i = 0; i < numOptional; i++) {
|
|
194
123
|
const ext = optionalPool[cryptoRandInt(0, optionalPool.length - 1)];
|
|
195
124
|
if (!baseExts.includes(ext))
|
|
196
125
|
baseExts.push(ext);
|
|
197
126
|
}
|
|
198
127
|
baseExts.sort();
|
|
199
|
-
// GLSL version
|
|
200
|
-
const
|
|
201
|
-
|
|
128
|
+
// GLSL version varies by vendor/driver generation
|
|
129
|
+
const glslVersionsByVendor = {
|
|
130
|
+
Intel: [
|
|
131
|
+
"OpenGL ES GLSL 3.00 (Build 31.0.101.2115)",
|
|
132
|
+
"OpenGL GLSL 4.60",
|
|
133
|
+
"OpenGL ES GLSL 3.00 (Build 31.0.101.2139)",
|
|
134
|
+
],
|
|
135
|
+
NVIDIA: [
|
|
136
|
+
"OpenGL GLSL 4.60 NVIDIA",
|
|
137
|
+
"OpenGL ES GLSL 3.00 NVIDIA",
|
|
138
|
+
"OpenGL GLSL 4.50 NVIDIA",
|
|
139
|
+
],
|
|
140
|
+
AMD: [
|
|
141
|
+
"OpenGL GLSL 4.60",
|
|
142
|
+
"OpenGL ES GLSL 3.00 (Builder ID:808)",
|
|
143
|
+
"OpenGL GLSL 4.50 AMD",
|
|
144
|
+
],
|
|
145
|
+
Mesa: [
|
|
146
|
+
"OpenGL GLSL 4.60 (adapter: Mesa; driver: ",
|
|
147
|
+
"OpenGL ES GLSL 3.00 (Mesa 23.2.1-1debian)",
|
|
148
|
+
"OpenGL GLSL 4.50 (Mesa 22.3.6)",
|
|
149
|
+
],
|
|
150
|
+
Apple: [
|
|
151
|
+
"OpenGL GLSL 4.1",
|
|
152
|
+
"OpenGL ES GLSL 3.00",
|
|
153
|
+
"Metal API GLSL 1.3.0",
|
|
154
|
+
],
|
|
155
|
+
"llvmpipe": [
|
|
156
|
+
"OpenGL GLSL 4.50 (Mesa 23.2.1)",
|
|
157
|
+
"OpenGL ES GLSL 3.00 (llvmpipe LLVM 15.0.7)",
|
|
158
|
+
],
|
|
159
|
+
Microsoft: ["OpenGL ES GLSL 1.0.0"],
|
|
160
|
+
Mozilla: ["OpenGL GLSL 4.60"],
|
|
161
|
+
Google: ["OpenGL ES GLSL 3.00"],
|
|
162
|
+
};
|
|
163
|
+
const vendorGlsl = glslVersionsByVendor[vendor.toLowerCase()] ?? ["OpenGL GLSL 4.60"];
|
|
202
164
|
const glslVersion = vendorGlsl[cryptoRandInt(0, vendorGlsl.length - 1)];
|
|
203
|
-
return { vendor, renderer:
|
|
165
|
+
return { vendor, renderer: gpu, webglExtensions: baseExts, glslVersion };
|
|
166
|
+
}
|
|
167
|
+
// Convenience wrapper using crypto-safe random
|
|
168
|
+
function cryptoRandInt(min, max) {
|
|
169
|
+
const buf = new Uint32Array(1);
|
|
170
|
+
crypto.getRandomValues(buf);
|
|
171
|
+
return min + (buf[0] % (max - min + 1));
|
|
204
172
|
}
|
|
205
173
|
export function resolveUAOS(userAgent) {
|
|
206
174
|
const parser = new UAParser(userAgent);
|
|
@@ -211,21 +179,3 @@ export function resolveUAOS(userAgent) {
|
|
|
211
179
|
return "win";
|
|
212
180
|
return "lin";
|
|
213
181
|
}
|
|
214
|
-
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
215
|
-
function cryptoRandInt(min, max) {
|
|
216
|
-
const buf = new Uint32Array(1);
|
|
217
|
-
crypto.getRandomValues(buf);
|
|
218
|
-
return min + (buf[0] % (max - min + 1));
|
|
219
|
-
}
|
|
220
|
-
function pickWeighted(items, weights) {
|
|
221
|
-
const total = weights.reduce((a, b) => a + b, 0);
|
|
222
|
-
const buf = new Uint32Array(1);
|
|
223
|
-
crypto.getRandomValues(buf);
|
|
224
|
-
let threshold = (buf[0] / 0x100000000) * total;
|
|
225
|
-
for (let i = 0; i < items.length; i++) {
|
|
226
|
-
threshold -= weights[i];
|
|
227
|
-
if (threshold <= 0)
|
|
228
|
-
return items[i];
|
|
229
|
-
}
|
|
230
|
-
return items[items.length - 1];
|
|
231
|
-
}
|