@skrillex1224/playwright-toolkit 3.0.7 → 3.0.8
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/dist/index.cjs +10 -97
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +10 -97
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5318,49 +5318,6 @@ var normalizeStringArray = (value) => {
|
|
|
5318
5318
|
}
|
|
5319
5319
|
return value.map((item) => String(item || "").trim()).filter(Boolean);
|
|
5320
5320
|
};
|
|
5321
|
-
var hashStableSeed = (value = "") => {
|
|
5322
|
-
const raw = String(value || "").trim();
|
|
5323
|
-
if (!raw) return "";
|
|
5324
|
-
let hash = 2166136261;
|
|
5325
|
-
for (let index = 0; index < raw.length; index += 1) {
|
|
5326
|
-
hash ^= raw.charCodeAt(index);
|
|
5327
|
-
hash = Math.imul(hash, 16777619);
|
|
5328
|
-
}
|
|
5329
|
-
const normalized = hash >>> 0 || 1;
|
|
5330
|
-
return String(normalized);
|
|
5331
|
-
};
|
|
5332
|
-
var extractProxySeedSource = (proxyConfiguration = {}) => {
|
|
5333
|
-
const config = normalizeObject2(proxyConfiguration);
|
|
5334
|
-
return String(config.proxy_url || "").trim();
|
|
5335
|
-
};
|
|
5336
|
-
var resolveCloakRuntimeHints = (runtimeState = {}, proxyConfiguration = {}, cloakOptions = {}) => {
|
|
5337
|
-
const normalizedCloakOptions = normalizeObject2(cloakOptions);
|
|
5338
|
-
const browserProfileCore = RuntimeEnv.getBrowserProfileCore(runtimeState);
|
|
5339
|
-
const baseConfig = DefaultAntiCheat.getBaseConfig();
|
|
5340
|
-
const locale = String(
|
|
5341
|
-
normalizedCloakOptions.locale || browserProfileCore?.locale || baseConfig.locale || ""
|
|
5342
|
-
).trim();
|
|
5343
|
-
const timezone = String(
|
|
5344
|
-
normalizedCloakOptions.timezone || normalizedCloakOptions.timezoneId || browserProfileCore?.timezone_id || baseConfig.timezoneId || ""
|
|
5345
|
-
).trim();
|
|
5346
|
-
const explicitArgs = normalizeStringArray(normalizedCloakOptions.args);
|
|
5347
|
-
const hasExplicitFingerprint = explicitArgs.some((arg) => arg.startsWith("--fingerprint="));
|
|
5348
|
-
const fingerprintSeedSource = String(
|
|
5349
|
-
runtimeState?.envId || browserProfileCore?.schema_version && JSON.stringify({
|
|
5350
|
-
envId: runtimeState?.envId || "",
|
|
5351
|
-
timezone: browserProfileCore?.timezone_id || "",
|
|
5352
|
-
locale: browserProfileCore?.locale || "",
|
|
5353
|
-
browserMajorVersion: browserProfileCore?.browser_major_version || "",
|
|
5354
|
-
device: browserProfileCore?.device || ""
|
|
5355
|
-
}) || extractProxySeedSource(proxyConfiguration)
|
|
5356
|
-
).trim();
|
|
5357
|
-
return {
|
|
5358
|
-
locale,
|
|
5359
|
-
timezone,
|
|
5360
|
-
fingerprintSeed: hasExplicitFingerprint ? "" : hashStableSeed(fingerprintSeedSource),
|
|
5361
|
-
hasExplicitFingerprint
|
|
5362
|
-
};
|
|
5363
|
-
};
|
|
5364
5321
|
var resolveCloakProxy = (proxyConfiguration = {}) => {
|
|
5365
5322
|
const config = normalizeObject2(proxyConfiguration);
|
|
5366
5323
|
const proxyUrl = String(config.proxy_url || "").trim();
|
|
@@ -5496,7 +5453,6 @@ var CloakLaunch = {
|
|
|
5496
5453
|
runInHeadfulMode = false,
|
|
5497
5454
|
isRunningOnApify = false,
|
|
5498
5455
|
launcher = null,
|
|
5499
|
-
runtimeState = null,
|
|
5500
5456
|
cloakOptions = {},
|
|
5501
5457
|
humanizeOptions = DEFAULT_CLOAK_HUMANIZE_OPTIONS,
|
|
5502
5458
|
crawlerBaseOptions = {},
|
|
@@ -5511,7 +5467,6 @@ var CloakLaunch = {
|
|
|
5511
5467
|
const patchedBrowsers = /* @__PURE__ */ new WeakSet();
|
|
5512
5468
|
const defaultArgs = isRunningOnApify ? ["--no-sandbox", "--disable-setuid-sandbox"] : [];
|
|
5513
5469
|
const extraArgs = normalizeStringArray(normalizedCloakOptions.args);
|
|
5514
|
-
const runtimeHints = resolveCloakRuntimeHints(runtimeState, proxyConfiguration, normalizedCloakOptions);
|
|
5515
5470
|
const hasExplicitProxy = hasOwn(normalizedCloakOptions, "proxy");
|
|
5516
5471
|
const proxyLaunchState = hasExplicitProxy ? resolveLaunchTraffic({ proxyConfiguration, debugMode, useMeter: false }) : resolveLaunchTraffic({ proxyConfiguration, debugMode });
|
|
5517
5472
|
const proxy = hasExplicitProxy ? normalizedCloakOptions.proxy : proxyLaunchState.launchProxy;
|
|
@@ -5521,13 +5476,7 @@ var CloakLaunch = {
|
|
|
5521
5476
|
...normalizedCloakOptions,
|
|
5522
5477
|
headless,
|
|
5523
5478
|
proxy,
|
|
5524
|
-
|
|
5525
|
-
...runtimeHints.timezone ? { timezone: runtimeHints.timezone } : {},
|
|
5526
|
-
args: [
|
|
5527
|
-
...defaultArgs,
|
|
5528
|
-
...extraArgs,
|
|
5529
|
-
...runtimeHints.fingerprintSeed ? [`--fingerprint=${runtimeHints.fingerprintSeed}`] : []
|
|
5530
|
-
]
|
|
5479
|
+
args: [...defaultArgs, ...extraArgs]
|
|
5531
5480
|
};
|
|
5532
5481
|
const launchOptions = await buildCloakLaunchOptions(mergedCloakOptions);
|
|
5533
5482
|
const fingerprintArg = extractFingerprintArg(launchOptions);
|
|
@@ -6354,7 +6303,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
6354
6303
|
let isStopped = false;
|
|
6355
6304
|
let isHandling = false;
|
|
6356
6305
|
let frameHandler = null;
|
|
6357
|
-
let
|
|
6306
|
+
let exposedFunctionName = null;
|
|
6358
6307
|
const triggerDetected = async () => {
|
|
6359
6308
|
if (isStopped || isHandling) return;
|
|
6360
6309
|
isHandling = true;
|
|
@@ -6366,16 +6315,12 @@ function useCaptchaMonitor(page, options) {
|
|
|
6366
6315
|
};
|
|
6367
6316
|
const cleanupFns = [];
|
|
6368
6317
|
if (domSelector) {
|
|
6369
|
-
|
|
6318
|
+
exposedFunctionName = `__c_d_${(0, import_uuid.v4)().replace(/-/g, "_")}`;
|
|
6370
6319
|
const cleanerName = `__c_cleaner_${(0, import_uuid.v4)().replace(/-/g, "_")}`;
|
|
6371
|
-
|
|
6320
|
+
page.exposeFunction(exposedFunctionName, triggerDetected).catch(() => {
|
|
6321
|
+
});
|
|
6322
|
+
page.addInitScript(({ selector, callbackName, cleanerName: cleanupName }) => {
|
|
6372
6323
|
(() => {
|
|
6373
|
-
if (typeof window[cleanupName] === "function") {
|
|
6374
|
-
try {
|
|
6375
|
-
window[cleanupName]();
|
|
6376
|
-
} catch {
|
|
6377
|
-
}
|
|
6378
|
-
}
|
|
6379
6324
|
let observer = null;
|
|
6380
6325
|
const checkAndReport = () => {
|
|
6381
6326
|
const element = document.querySelector(selector);
|
|
@@ -6401,7 +6346,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
6401
6346
|
}
|
|
6402
6347
|
};
|
|
6403
6348
|
if (document.readyState === "loading") {
|
|
6404
|
-
window.addEventListener("DOMContentLoaded", mountObserver
|
|
6349
|
+
window.addEventListener("DOMContentLoaded", mountObserver);
|
|
6405
6350
|
} else {
|
|
6406
6351
|
mountObserver();
|
|
6407
6352
|
}
|
|
@@ -6412,41 +6357,9 @@ function useCaptchaMonitor(page, options) {
|
|
|
6412
6357
|
}
|
|
6413
6358
|
};
|
|
6414
6359
|
})();
|
|
6415
|
-
};
|
|
6416
|
-
|
|
6417
|
-
selector: domSelector,
|
|
6418
|
-
callbackName: exposedFunctionName,
|
|
6419
|
-
cleanerName
|
|
6420
|
-
};
|
|
6421
|
-
const domMonitorReady = (async () => {
|
|
6422
|
-
await page.exposeFunction(exposedFunctionName, triggerDetected);
|
|
6423
|
-
await page.addInitScript(installDomMonitor, installArgs);
|
|
6424
|
-
await page.evaluate(installDomMonitor, installArgs).catch(() => {
|
|
6425
|
-
});
|
|
6426
|
-
logger12.success("useCaptchaMonitor", `DOM \u76D1\u63A7\u5DF2\u542F\u7528\uFF1A${domSelector}`);
|
|
6427
|
-
})().catch((error) => {
|
|
6428
|
-
if (isStopped) {
|
|
6429
|
-
return;
|
|
6430
|
-
}
|
|
6431
|
-
logger12.warn(`DOM \u76D1\u63A7\u521D\u59CB\u5316\u5931\u8D25 (${domSelector}): ${error?.message || error}`);
|
|
6432
|
-
});
|
|
6433
|
-
domFrameHandler = async (frame) => {
|
|
6434
|
-
if (frame !== page.mainFrame() || isStopped) {
|
|
6435
|
-
return;
|
|
6436
|
-
}
|
|
6437
|
-
await domMonitorReady;
|
|
6438
|
-
if (isStopped) {
|
|
6439
|
-
return;
|
|
6440
|
-
}
|
|
6441
|
-
await page.evaluate(installDomMonitor, installArgs).catch(() => {
|
|
6442
|
-
});
|
|
6443
|
-
};
|
|
6444
|
-
page.on("framenavigated", domFrameHandler);
|
|
6360
|
+
}, { selector: domSelector, callbackName: exposedFunctionName, cleanerName });
|
|
6361
|
+
logger12.success("useCaptchaMonitor", `DOM \u76D1\u63A7\u5DF2\u542F\u7528\uFF1A${domSelector}`);
|
|
6445
6362
|
cleanupFns.push(async () => {
|
|
6446
|
-
if (domFrameHandler) {
|
|
6447
|
-
page.off("framenavigated", domFrameHandler);
|
|
6448
|
-
}
|
|
6449
|
-
await domMonitorReady;
|
|
6450
6363
|
try {
|
|
6451
6364
|
await page.evaluate((name) => {
|
|
6452
6365
|
if (window[name]) {
|
|
@@ -6477,10 +6390,10 @@ function useCaptchaMonitor(page, options) {
|
|
|
6477
6390
|
return {
|
|
6478
6391
|
stop: async () => {
|
|
6479
6392
|
logger12.info("\u6B63\u5728\u505C\u6B62\u9A8C\u8BC1\u7801\u76D1\u63A7...");
|
|
6480
|
-
isStopped = true;
|
|
6481
6393
|
for (const fn of cleanupFns) {
|
|
6482
6394
|
await fn();
|
|
6483
6395
|
}
|
|
6396
|
+
isStopped = true;
|
|
6484
6397
|
}
|
|
6485
6398
|
};
|
|
6486
6399
|
}
|