@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.js
CHANGED
|
@@ -5290,49 +5290,6 @@ var normalizeStringArray = (value) => {
|
|
|
5290
5290
|
}
|
|
5291
5291
|
return value.map((item) => String(item || "").trim()).filter(Boolean);
|
|
5292
5292
|
};
|
|
5293
|
-
var hashStableSeed = (value = "") => {
|
|
5294
|
-
const raw = String(value || "").trim();
|
|
5295
|
-
if (!raw) return "";
|
|
5296
|
-
let hash = 2166136261;
|
|
5297
|
-
for (let index = 0; index < raw.length; index += 1) {
|
|
5298
|
-
hash ^= raw.charCodeAt(index);
|
|
5299
|
-
hash = Math.imul(hash, 16777619);
|
|
5300
|
-
}
|
|
5301
|
-
const normalized = hash >>> 0 || 1;
|
|
5302
|
-
return String(normalized);
|
|
5303
|
-
};
|
|
5304
|
-
var extractProxySeedSource = (proxyConfiguration = {}) => {
|
|
5305
|
-
const config = normalizeObject2(proxyConfiguration);
|
|
5306
|
-
return String(config.proxy_url || "").trim();
|
|
5307
|
-
};
|
|
5308
|
-
var resolveCloakRuntimeHints = (runtimeState = {}, proxyConfiguration = {}, cloakOptions = {}) => {
|
|
5309
|
-
const normalizedCloakOptions = normalizeObject2(cloakOptions);
|
|
5310
|
-
const browserProfileCore = RuntimeEnv.getBrowserProfileCore(runtimeState);
|
|
5311
|
-
const baseConfig = DefaultAntiCheat.getBaseConfig();
|
|
5312
|
-
const locale = String(
|
|
5313
|
-
normalizedCloakOptions.locale || browserProfileCore?.locale || baseConfig.locale || ""
|
|
5314
|
-
).trim();
|
|
5315
|
-
const timezone = String(
|
|
5316
|
-
normalizedCloakOptions.timezone || normalizedCloakOptions.timezoneId || browserProfileCore?.timezone_id || baseConfig.timezoneId || ""
|
|
5317
|
-
).trim();
|
|
5318
|
-
const explicitArgs = normalizeStringArray(normalizedCloakOptions.args);
|
|
5319
|
-
const hasExplicitFingerprint = explicitArgs.some((arg) => arg.startsWith("--fingerprint="));
|
|
5320
|
-
const fingerprintSeedSource = String(
|
|
5321
|
-
runtimeState?.envId || browserProfileCore?.schema_version && JSON.stringify({
|
|
5322
|
-
envId: runtimeState?.envId || "",
|
|
5323
|
-
timezone: browserProfileCore?.timezone_id || "",
|
|
5324
|
-
locale: browserProfileCore?.locale || "",
|
|
5325
|
-
browserMajorVersion: browserProfileCore?.browser_major_version || "",
|
|
5326
|
-
device: browserProfileCore?.device || ""
|
|
5327
|
-
}) || extractProxySeedSource(proxyConfiguration)
|
|
5328
|
-
).trim();
|
|
5329
|
-
return {
|
|
5330
|
-
locale,
|
|
5331
|
-
timezone,
|
|
5332
|
-
fingerprintSeed: hasExplicitFingerprint ? "" : hashStableSeed(fingerprintSeedSource),
|
|
5333
|
-
hasExplicitFingerprint
|
|
5334
|
-
};
|
|
5335
|
-
};
|
|
5336
5293
|
var resolveCloakProxy = (proxyConfiguration = {}) => {
|
|
5337
5294
|
const config = normalizeObject2(proxyConfiguration);
|
|
5338
5295
|
const proxyUrl = String(config.proxy_url || "").trim();
|
|
@@ -5468,7 +5425,6 @@ var CloakLaunch = {
|
|
|
5468
5425
|
runInHeadfulMode = false,
|
|
5469
5426
|
isRunningOnApify = false,
|
|
5470
5427
|
launcher = null,
|
|
5471
|
-
runtimeState = null,
|
|
5472
5428
|
cloakOptions = {},
|
|
5473
5429
|
humanizeOptions = DEFAULT_CLOAK_HUMANIZE_OPTIONS,
|
|
5474
5430
|
crawlerBaseOptions = {},
|
|
@@ -5483,7 +5439,6 @@ var CloakLaunch = {
|
|
|
5483
5439
|
const patchedBrowsers = /* @__PURE__ */ new WeakSet();
|
|
5484
5440
|
const defaultArgs = isRunningOnApify ? ["--no-sandbox", "--disable-setuid-sandbox"] : [];
|
|
5485
5441
|
const extraArgs = normalizeStringArray(normalizedCloakOptions.args);
|
|
5486
|
-
const runtimeHints = resolveCloakRuntimeHints(runtimeState, proxyConfiguration, normalizedCloakOptions);
|
|
5487
5442
|
const hasExplicitProxy = hasOwn(normalizedCloakOptions, "proxy");
|
|
5488
5443
|
const proxyLaunchState = hasExplicitProxy ? resolveLaunchTraffic({ proxyConfiguration, debugMode, useMeter: false }) : resolveLaunchTraffic({ proxyConfiguration, debugMode });
|
|
5489
5444
|
const proxy = hasExplicitProxy ? normalizedCloakOptions.proxy : proxyLaunchState.launchProxy;
|
|
@@ -5493,13 +5448,7 @@ var CloakLaunch = {
|
|
|
5493
5448
|
...normalizedCloakOptions,
|
|
5494
5449
|
headless,
|
|
5495
5450
|
proxy,
|
|
5496
|
-
|
|
5497
|
-
...runtimeHints.timezone ? { timezone: runtimeHints.timezone } : {},
|
|
5498
|
-
args: [
|
|
5499
|
-
...defaultArgs,
|
|
5500
|
-
...extraArgs,
|
|
5501
|
-
...runtimeHints.fingerprintSeed ? [`--fingerprint=${runtimeHints.fingerprintSeed}`] : []
|
|
5502
|
-
]
|
|
5451
|
+
args: [...defaultArgs, ...extraArgs]
|
|
5503
5452
|
};
|
|
5504
5453
|
const launchOptions = await buildCloakLaunchOptions(mergedCloakOptions);
|
|
5505
5454
|
const fingerprintArg = extractFingerprintArg(launchOptions);
|
|
@@ -6326,7 +6275,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
6326
6275
|
let isStopped = false;
|
|
6327
6276
|
let isHandling = false;
|
|
6328
6277
|
let frameHandler = null;
|
|
6329
|
-
let
|
|
6278
|
+
let exposedFunctionName = null;
|
|
6330
6279
|
const triggerDetected = async () => {
|
|
6331
6280
|
if (isStopped || isHandling) return;
|
|
6332
6281
|
isHandling = true;
|
|
@@ -6338,16 +6287,12 @@ function useCaptchaMonitor(page, options) {
|
|
|
6338
6287
|
};
|
|
6339
6288
|
const cleanupFns = [];
|
|
6340
6289
|
if (domSelector) {
|
|
6341
|
-
|
|
6290
|
+
exposedFunctionName = `__c_d_${uuidv4().replace(/-/g, "_")}`;
|
|
6342
6291
|
const cleanerName = `__c_cleaner_${uuidv4().replace(/-/g, "_")}`;
|
|
6343
|
-
|
|
6292
|
+
page.exposeFunction(exposedFunctionName, triggerDetected).catch(() => {
|
|
6293
|
+
});
|
|
6294
|
+
page.addInitScript(({ selector, callbackName, cleanerName: cleanupName }) => {
|
|
6344
6295
|
(() => {
|
|
6345
|
-
if (typeof window[cleanupName] === "function") {
|
|
6346
|
-
try {
|
|
6347
|
-
window[cleanupName]();
|
|
6348
|
-
} catch {
|
|
6349
|
-
}
|
|
6350
|
-
}
|
|
6351
6296
|
let observer = null;
|
|
6352
6297
|
const checkAndReport = () => {
|
|
6353
6298
|
const element = document.querySelector(selector);
|
|
@@ -6373,7 +6318,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
6373
6318
|
}
|
|
6374
6319
|
};
|
|
6375
6320
|
if (document.readyState === "loading") {
|
|
6376
|
-
window.addEventListener("DOMContentLoaded", mountObserver
|
|
6321
|
+
window.addEventListener("DOMContentLoaded", mountObserver);
|
|
6377
6322
|
} else {
|
|
6378
6323
|
mountObserver();
|
|
6379
6324
|
}
|
|
@@ -6384,41 +6329,9 @@ function useCaptchaMonitor(page, options) {
|
|
|
6384
6329
|
}
|
|
6385
6330
|
};
|
|
6386
6331
|
})();
|
|
6387
|
-
};
|
|
6388
|
-
|
|
6389
|
-
selector: domSelector,
|
|
6390
|
-
callbackName: exposedFunctionName,
|
|
6391
|
-
cleanerName
|
|
6392
|
-
};
|
|
6393
|
-
const domMonitorReady = (async () => {
|
|
6394
|
-
await page.exposeFunction(exposedFunctionName, triggerDetected);
|
|
6395
|
-
await page.addInitScript(installDomMonitor, installArgs);
|
|
6396
|
-
await page.evaluate(installDomMonitor, installArgs).catch(() => {
|
|
6397
|
-
});
|
|
6398
|
-
logger12.success("useCaptchaMonitor", `DOM \u76D1\u63A7\u5DF2\u542F\u7528\uFF1A${domSelector}`);
|
|
6399
|
-
})().catch((error) => {
|
|
6400
|
-
if (isStopped) {
|
|
6401
|
-
return;
|
|
6402
|
-
}
|
|
6403
|
-
logger12.warn(`DOM \u76D1\u63A7\u521D\u59CB\u5316\u5931\u8D25 (${domSelector}): ${error?.message || error}`);
|
|
6404
|
-
});
|
|
6405
|
-
domFrameHandler = async (frame) => {
|
|
6406
|
-
if (frame !== page.mainFrame() || isStopped) {
|
|
6407
|
-
return;
|
|
6408
|
-
}
|
|
6409
|
-
await domMonitorReady;
|
|
6410
|
-
if (isStopped) {
|
|
6411
|
-
return;
|
|
6412
|
-
}
|
|
6413
|
-
await page.evaluate(installDomMonitor, installArgs).catch(() => {
|
|
6414
|
-
});
|
|
6415
|
-
};
|
|
6416
|
-
page.on("framenavigated", domFrameHandler);
|
|
6332
|
+
}, { selector: domSelector, callbackName: exposedFunctionName, cleanerName });
|
|
6333
|
+
logger12.success("useCaptchaMonitor", `DOM \u76D1\u63A7\u5DF2\u542F\u7528\uFF1A${domSelector}`);
|
|
6417
6334
|
cleanupFns.push(async () => {
|
|
6418
|
-
if (domFrameHandler) {
|
|
6419
|
-
page.off("framenavigated", domFrameHandler);
|
|
6420
|
-
}
|
|
6421
|
-
await domMonitorReady;
|
|
6422
6335
|
try {
|
|
6423
6336
|
await page.evaluate((name) => {
|
|
6424
6337
|
if (window[name]) {
|
|
@@ -6449,10 +6362,10 @@ function useCaptchaMonitor(page, options) {
|
|
|
6449
6362
|
return {
|
|
6450
6363
|
stop: async () => {
|
|
6451
6364
|
logger12.info("\u6B63\u5728\u505C\u6B62\u9A8C\u8BC1\u7801\u76D1\u63A7...");
|
|
6452
|
-
isStopped = true;
|
|
6453
6365
|
for (const fn of cleanupFns) {
|
|
6454
6366
|
await fn();
|
|
6455
6367
|
}
|
|
6368
|
+
isStopped = true;
|
|
6456
6369
|
}
|
|
6457
6370
|
};
|
|
6458
6371
|
}
|