@skrillex1224/playwright-toolkit 3.0.2 → 3.0.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/dist/index.cjs +261 -293
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +261 -293
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -387,18 +387,18 @@ var fallbackLog = {
|
|
|
387
387
|
error: (...args) => console.error(...args),
|
|
388
388
|
debug: (...args) => console.debug ? console.debug(...args) : console.log(...args)
|
|
389
389
|
};
|
|
390
|
-
var resolveLogMethod = (
|
|
391
|
-
if (
|
|
392
|
-
return
|
|
390
|
+
var resolveLogMethod = (logger17, name) => {
|
|
391
|
+
if (logger17 && typeof logger17[name] === "function") {
|
|
392
|
+
return logger17[name].bind(logger17);
|
|
393
393
|
}
|
|
394
|
-
if (name === "warning" &&
|
|
395
|
-
return
|
|
394
|
+
if (name === "warning" && logger17 && typeof logger17.warn === "function") {
|
|
395
|
+
return logger17.warn.bind(logger17);
|
|
396
396
|
}
|
|
397
397
|
return fallbackLog[name];
|
|
398
398
|
};
|
|
399
399
|
var defaultLogger = null;
|
|
400
|
-
var setDefaultLogger = (
|
|
401
|
-
defaultLogger =
|
|
400
|
+
var setDefaultLogger = (logger17) => {
|
|
401
|
+
defaultLogger = logger17;
|
|
402
402
|
};
|
|
403
403
|
var resolveLogger = (explicitLogger) => {
|
|
404
404
|
if (explicitLogger && typeof explicitLogger.info === "function") {
|
|
@@ -425,8 +425,8 @@ var colorize = (text, color) => {
|
|
|
425
425
|
var createBaseLogger = (prefix = "", explicitLogger) => {
|
|
426
426
|
const name = prefix ? String(prefix) : "";
|
|
427
427
|
const dispatch = (methodName, icon, message, color) => {
|
|
428
|
-
const
|
|
429
|
-
const logFn = resolveLogMethod(
|
|
428
|
+
const logger17 = resolveLogger(explicitLogger);
|
|
429
|
+
const logFn = resolveLogMethod(logger17, methodName);
|
|
430
430
|
const timestamp = colorize(`[${formatTimestamp()}]`, ANSI.gray);
|
|
431
431
|
const line = formatLine(name, icon, message);
|
|
432
432
|
const coloredLine = colorize(line, color);
|
|
@@ -4865,9 +4865,107 @@ var ByPass = {
|
|
|
4865
4865
|
resolveRouteByProxy
|
|
4866
4866
|
};
|
|
4867
4867
|
|
|
4868
|
-
// src/internals/launch/
|
|
4868
|
+
// src/internals/launch/traffic.js
|
|
4869
4869
|
var logger7 = createInternalLogger("Launch");
|
|
4870
|
-
var
|
|
4870
|
+
var normalizeObject = (value) => {
|
|
4871
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
4872
|
+
return {};
|
|
4873
|
+
}
|
|
4874
|
+
return value;
|
|
4875
|
+
};
|
|
4876
|
+
var parseProxyConfiguration = (proxyConfiguration = {}) => {
|
|
4877
|
+
const config = normalizeObject(proxyConfiguration);
|
|
4878
|
+
const proxyUrl = String(config.proxy_url || "").trim();
|
|
4879
|
+
const enableProxy = typeof config.enable_proxy === "boolean" ? config.enable_proxy : proxyUrl !== "";
|
|
4880
|
+
const byPassDomains = enableProxy && proxyUrl ? ByPass.normalizeByPassDomains(config.by_pass_domains) : [];
|
|
4881
|
+
return {
|
|
4882
|
+
byPassDomains,
|
|
4883
|
+
enableProxy,
|
|
4884
|
+
proxyUrl
|
|
4885
|
+
};
|
|
4886
|
+
};
|
|
4887
|
+
var resolveLaunchTraffic = ({
|
|
4888
|
+
proxyConfiguration = {},
|
|
4889
|
+
debugMode = false,
|
|
4890
|
+
useMeter = true
|
|
4891
|
+
} = {}) => {
|
|
4892
|
+
const { byPassDomains, enableProxy, proxyUrl } = parseProxyConfiguration(proxyConfiguration);
|
|
4893
|
+
const byPassRules = ByPass.buildByPassDomainRules(byPassDomains);
|
|
4894
|
+
const proxyMeter = useMeter && enableProxy && proxyUrl ? ProxyMeterRuntime.startProxyMeter({ proxyUrl, debugMode }) : null;
|
|
4895
|
+
const launchProxy = proxyMeter ? { server: proxyMeter.server } : null;
|
|
4896
|
+
if (launchProxy && byPassDomains.length > 0) {
|
|
4897
|
+
launchProxy.bypass = byPassDomains.join(",");
|
|
4898
|
+
}
|
|
4899
|
+
return {
|
|
4900
|
+
byPassDomains,
|
|
4901
|
+
byPassRules,
|
|
4902
|
+
enableProxy,
|
|
4903
|
+
proxyUrl,
|
|
4904
|
+
launchProxy
|
|
4905
|
+
};
|
|
4906
|
+
};
|
|
4907
|
+
var logLaunchTraffic = ({
|
|
4908
|
+
byPassDomains = [],
|
|
4909
|
+
debugMode = false,
|
|
4910
|
+
enabled = false,
|
|
4911
|
+
enableProxy = false,
|
|
4912
|
+
explicitProxy = false,
|
|
4913
|
+
launchProxy = null,
|
|
4914
|
+
proxyUrl = ""
|
|
4915
|
+
} = {}) => {
|
|
4916
|
+
if (!enabled) return;
|
|
4917
|
+
if (explicitProxy) {
|
|
4918
|
+
logger7.info("[\u4EE3\u7406\u5DF2\u542F\u7528] \u4F7F\u7528\u663E\u5F0F proxy \u914D\u7F6E\uFF0C\u8DF3\u8FC7 toolkit \u672C\u5730\u6D41\u91CF\u89C2\u6D4B");
|
|
4919
|
+
return;
|
|
4920
|
+
}
|
|
4921
|
+
if (launchProxy) {
|
|
4922
|
+
let upstreamLabel = "";
|
|
4923
|
+
try {
|
|
4924
|
+
const parsedProxyUrl = new URL(proxyUrl.includes("://") ? proxyUrl : `http://${proxyUrl}`);
|
|
4925
|
+
upstreamLabel = `${parsedProxyUrl.protocol}//${parsedProxyUrl.host}`;
|
|
4926
|
+
} catch {
|
|
4927
|
+
}
|
|
4928
|
+
logger7.info(
|
|
4929
|
+
`[\u4EE3\u7406\u5DF2\u542F\u7528] \u672C\u5730=${launchProxy.server} \u4E0A\u6E38=${upstreamLabel || "-"} \u76F4\u8FDE\u57DF\u540D=${byPassDomains.join(",")}`
|
|
4930
|
+
);
|
|
4931
|
+
logger7.info(`[\u6D41\u91CF\u89C2\u6D4B] \u9010\u8BF7\u6C42\u8C03\u8BD5=${Boolean(debugMode) ? "\u5F00\u542F" : "\u5173\u95ED"}\uFF08\u6C47\u603B\u59CB\u7EC8\u5F00\u542F\uFF09`);
|
|
4932
|
+
return;
|
|
4933
|
+
}
|
|
4934
|
+
if (enableProxy) {
|
|
4935
|
+
logger7.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=true \u4F46 proxy_url \u4E3A\u7A7A");
|
|
4936
|
+
} else if (proxyUrl) {
|
|
4937
|
+
logger7.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=false \u4E14 proxy_url \u5DF2\u914D\u7F6E");
|
|
4938
|
+
}
|
|
4939
|
+
logger7.info(`[\u6D41\u91CF\u89C2\u6D4B] \u9010\u8BF7\u6C42\u8C03\u8BD5=${Boolean(debugMode) ? "\u5F00\u542F" : "\u5173\u95ED"}\uFF08\u6C47\u603B\u59CB\u7EC8\u5F00\u542F\uFF09`);
|
|
4940
|
+
};
|
|
4941
|
+
var createLaunchTrafficHook = ({
|
|
4942
|
+
byPassDomains = [],
|
|
4943
|
+
byPassRules = [],
|
|
4944
|
+
enabled = false,
|
|
4945
|
+
launchProxy = null
|
|
4946
|
+
} = {}) => {
|
|
4947
|
+
const patchedPages = /* @__PURE__ */ new WeakSet();
|
|
4948
|
+
return (page) => {
|
|
4949
|
+
if (!page || typeof page.on !== "function" || patchedPages.has(page)) {
|
|
4950
|
+
return;
|
|
4951
|
+
}
|
|
4952
|
+
patchedPages.add(page);
|
|
4953
|
+
page.on("request", (req) => {
|
|
4954
|
+
const requestUrl = req.url();
|
|
4955
|
+
const resourceType = req.resourceType();
|
|
4956
|
+
const matched = byPassDomains.length > 0 ? ByPass.findMatchedByPassRule(byPassRules, requestUrl) : null;
|
|
4957
|
+
if (launchProxy) {
|
|
4958
|
+
ProxyMeterRuntime.recordProxyMeterResourceType(requestUrl, resourceType);
|
|
4959
|
+
}
|
|
4960
|
+
if (!enabled || byPassDomains.length === 0) return;
|
|
4961
|
+
if (!matched || !matched.rule) return;
|
|
4962
|
+
logger7.info(`[\u76F4\u8FDE\u547D\u4E2D] \u89C4\u5219=${matched.rule.pattern} \u57DF\u540D=${matched.hostname} \u8D44\u6E90\u7C7B\u578B=${resourceType} \u65B9\u6CD5=${req.method()} \u5730\u5740=${requestUrl}`);
|
|
4963
|
+
});
|
|
4964
|
+
};
|
|
4965
|
+
};
|
|
4966
|
+
|
|
4967
|
+
// src/internals/launch/default.js
|
|
4968
|
+
var logger8 = createInternalLogger("Launch");
|
|
4871
4969
|
var injectedContexts = /* @__PURE__ */ new WeakSet();
|
|
4872
4970
|
var browserMajorVersionCache = /* @__PURE__ */ new Map();
|
|
4873
4971
|
var DEFAULT_BROWSER_PROFILE_SCHEMA_VERSION = 1;
|
|
@@ -4879,16 +4977,6 @@ var DEFAULT_CRAWLER_BASE_OPTIONS = Object.freeze({
|
|
|
4879
4977
|
navigationTimeoutSecs: 120
|
|
4880
4978
|
});
|
|
4881
4979
|
var fingerprintInjector = new import_fingerprint_injector.FingerprintInjector();
|
|
4882
|
-
var resolveProxyLaunchOptions = (proxyConfiguration = {}) => {
|
|
4883
|
-
const config = proxyConfiguration && typeof proxyConfiguration === "object" && !Array.isArray(proxyConfiguration) ? proxyConfiguration : {};
|
|
4884
|
-
const proxyUrl = String(config.proxy_url || "").trim();
|
|
4885
|
-
const enableProxy = typeof config.enable_proxy === "boolean" ? config.enable_proxy : proxyUrl !== "";
|
|
4886
|
-
if (!enableProxy || !proxyUrl) {
|
|
4887
|
-
return { byPassDomains: [], enableProxy, proxyUrl };
|
|
4888
|
-
}
|
|
4889
|
-
const byPassDomains = ByPass.normalizeByPassDomains(config.by_pass_domains);
|
|
4890
|
-
return { byPassDomains, enableProxy, proxyUrl };
|
|
4891
|
-
};
|
|
4892
4980
|
var parseChromeMajorVersion = (rawValue = "") => {
|
|
4893
4981
|
const match = String(rawValue || "").match(/(?:Chrome|Chromium)(?:\/|\s+(?:for Testing\s+)?)(\d+)/i);
|
|
4894
4982
|
return match ? Number(match[1] || 0) : 0;
|
|
@@ -4918,7 +5006,7 @@ var detectBrowserMajorVersion = (launcher) => {
|
|
|
4918
5006
|
});
|
|
4919
5007
|
detectedVersion = parseChromeMajorVersion(rawVersion);
|
|
4920
5008
|
} catch (error) {
|
|
4921
|
-
|
|
5009
|
+
logger8.warn(`\u8BFB\u53D6\u6D4F\u89C8\u5668\u7248\u672C\u5931\u8D25: ${error?.message || error}`);
|
|
4922
5010
|
}
|
|
4923
5011
|
browserMajorVersionCache.set(executablePath, detectedVersion);
|
|
4924
5012
|
return detectedVersion;
|
|
@@ -4955,7 +5043,7 @@ var generateFingerprintForCore = ({ locale, browserMajorVersion, device }) => {
|
|
|
4955
5043
|
if (requestedBrowserMajorVersion <= 0) {
|
|
4956
5044
|
throw error;
|
|
4957
5045
|
}
|
|
4958
|
-
|
|
5046
|
+
logger8.warn(
|
|
4959
5047
|
`\u5F53\u524D\u6D4F\u89C8\u5668\u5927\u7248\u672C ${requestedBrowserMajorVersion} \u65E0\u53EF\u7528 strict \u6307\u7EB9\u6837\u672C\uFF0C\u9000\u56DE\u4E0D\u7ED1\u5B9A\u5927\u7248\u672C\u751F\u6210: ${error?.message || error}`
|
|
4960
5048
|
);
|
|
4961
5049
|
}
|
|
@@ -5000,7 +5088,7 @@ var buildReplayableBrowserProfile = (runtimeState, launcher) => {
|
|
|
5000
5088
|
schema_version: DEFAULT_BROWSER_PROFILE_SCHEMA_VERSION
|
|
5001
5089
|
};
|
|
5002
5090
|
nextState = RuntimeEnv.setBrowserProfileCore(nextState, browserProfileCore);
|
|
5003
|
-
|
|
5091
|
+
logger8.info(
|
|
5004
5092
|
`\u5DF2\u751F\u6210\u6D4F\u89C8\u5668\u6307\u7EB9\u771F\u6E90 | env=${String(nextState.envId || "-")} | device=${device} | version=${browserProfileCore.browser_major_version || "-"} | fingerprintVersion=${fingerprintBrowserMajorVersion || "-"} | exactVersion=${generated.exactBrowserMajorVersion ? "true" : "false"} | timezone=${timezoneId}`
|
|
5005
5093
|
);
|
|
5006
5094
|
return { runtimeState: nextState, browserProfileCore };
|
|
@@ -5101,13 +5189,12 @@ var DefaultLaunch = {
|
|
|
5101
5189
|
runtimeState = null
|
|
5102
5190
|
} = normalizedOptions;
|
|
5103
5191
|
const device = resolveRuntimeDevice(runtimeState);
|
|
5104
|
-
const
|
|
5105
|
-
const
|
|
5106
|
-
const
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
}
|
|
5192
|
+
const enableByPassLogger = Boolean(logOptions && logOptions.enable);
|
|
5193
|
+
const traffic = resolveLaunchTraffic({ proxyConfiguration, debugMode });
|
|
5194
|
+
const trafficHook = createLaunchTrafficHook({
|
|
5195
|
+
...traffic,
|
|
5196
|
+
enabled: enableByPassLogger
|
|
5197
|
+
});
|
|
5111
5198
|
const replayContext = buildReplayableBrowserProfile(runtimeState, launcher);
|
|
5112
5199
|
const replayBrowserPoolOptions = buildReplayBrowserPoolOptions(replayContext.browserProfileCore);
|
|
5113
5200
|
const launchLocale = String(replayContext.browserProfileCore?.locale || DEFAULT_LOCALE).trim() || DEFAULT_LOCALE;
|
|
@@ -5118,30 +5205,14 @@ var DefaultLaunch = {
|
|
|
5118
5205
|
],
|
|
5119
5206
|
ignoreDefaultArgs: ["--enable-automation"]
|
|
5120
5207
|
};
|
|
5121
|
-
if (launchProxy) {
|
|
5122
|
-
launchOptions.proxy = launchProxy;
|
|
5123
|
-
}
|
|
5124
|
-
const enableByPassLogger = Boolean(logOptions && logOptions.enable);
|
|
5125
|
-
if (enableByPassLogger && launchProxy) {
|
|
5126
|
-
let upstreamLabel = "";
|
|
5127
|
-
try {
|
|
5128
|
-
const parsedProxyUrl = new URL(proxyUrl.includes("://") ? proxyUrl : `http://${proxyUrl}`);
|
|
5129
|
-
upstreamLabel = `${parsedProxyUrl.protocol}//${parsedProxyUrl.host}`;
|
|
5130
|
-
} catch {
|
|
5131
|
-
}
|
|
5132
|
-
logger7.info(
|
|
5133
|
-
`[\u4EE3\u7406\u5DF2\u542F\u7528] \u672C\u5730=${launchProxy.server} \u4E0A\u6E38=${upstreamLabel || "-"} \u76F4\u8FDE\u57DF\u540D=${(byPassDomains || []).join(",")}`
|
|
5134
|
-
);
|
|
5135
|
-
logger7.info(`[\u6D41\u91CF\u89C2\u6D4B] \u9010\u8BF7\u6C42\u8C03\u8BD5=${Boolean(debugMode) ? "\u5F00\u542F" : "\u5173\u95ED"}\uFF08\u6C47\u603B\u59CB\u7EC8\u5F00\u542F\uFF09`);
|
|
5136
|
-
} else if (enableByPassLogger && enableProxy && !launchProxy) {
|
|
5137
|
-
logger7.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=true \u4F46 proxy_url \u4E3A\u7A7A");
|
|
5138
|
-
logger7.info(`[\u6D41\u91CF\u89C2\u6D4B] \u9010\u8BF7\u6C42\u8C03\u8BD5=${Boolean(debugMode) ? "\u5F00\u542F" : "\u5173\u95ED"}\uFF08\u6C47\u603B\u59CB\u7EC8\u5F00\u542F\uFF09`);
|
|
5139
|
-
} else if (enableByPassLogger && !enableProxy && proxyUrl) {
|
|
5140
|
-
logger7.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=false \u4E14 proxy_url \u5DF2\u914D\u7F6E");
|
|
5141
|
-
logger7.info(`[\u6D41\u91CF\u89C2\u6D4B] \u9010\u8BF7\u6C42\u8C03\u8BD5=${Boolean(debugMode) ? "\u5F00\u542F" : "\u5173\u95ED"}\uFF08\u6C47\u603B\u59CB\u7EC8\u5F00\u542F\uFF09`);
|
|
5142
|
-
} else if (enableByPassLogger) {
|
|
5143
|
-
logger7.info(`[\u6D41\u91CF\u89C2\u6D4B] \u9010\u8BF7\u6C42\u8C03\u8BD5=${Boolean(debugMode) ? "\u5F00\u542F" : "\u5173\u95ED"}\uFF08\u6C47\u603B\u59CB\u7EC8\u5F00\u542F\uFF09`);
|
|
5208
|
+
if (traffic.launchProxy) {
|
|
5209
|
+
launchOptions.proxy = traffic.launchProxy;
|
|
5144
5210
|
}
|
|
5211
|
+
logLaunchTraffic({
|
|
5212
|
+
...traffic,
|
|
5213
|
+
debugMode,
|
|
5214
|
+
enabled: enableByPassLogger
|
|
5215
|
+
});
|
|
5145
5216
|
const onPageCreated = (page) => {
|
|
5146
5217
|
const recommendedGotoOptions = {
|
|
5147
5218
|
waitUntil: "commit"
|
|
@@ -5149,22 +5220,7 @@ var DefaultLaunch = {
|
|
|
5149
5220
|
if (!page || typeof page.on !== "function") {
|
|
5150
5221
|
return recommendedGotoOptions;
|
|
5151
5222
|
}
|
|
5152
|
-
|
|
5153
|
-
return recommendedGotoOptions;
|
|
5154
|
-
}
|
|
5155
|
-
page[REQUEST_HOOK_FLAG] = true;
|
|
5156
|
-
const requestHandler = (req) => {
|
|
5157
|
-
const requestUrl = req.url();
|
|
5158
|
-
const resourceType = req.resourceType();
|
|
5159
|
-
const matched = byPassDomains.length > 0 ? ByPass.findMatchedByPassRule(byPassRules, requestUrl) : null;
|
|
5160
|
-
if (launchProxy) {
|
|
5161
|
-
ProxyMeterRuntime.recordProxyMeterResourceType(requestUrl, resourceType);
|
|
5162
|
-
}
|
|
5163
|
-
if (!enableByPassLogger || byPassDomains.length === 0) return;
|
|
5164
|
-
if (!matched || !matched.rule) return;
|
|
5165
|
-
logger7.info(`[\u76F4\u8FDE\u547D\u4E2D] \u89C4\u5219=${matched.rule.pattern} \u57DF\u540D=${matched.hostname} \u8D44\u6E90\u7C7B\u578B=${resourceType} \u65B9\u6CD5=${req.method()} \u5730\u5740=${requestUrl}`);
|
|
5166
|
-
};
|
|
5167
|
-
page.on("request", requestHandler);
|
|
5223
|
+
trafficHook(page);
|
|
5168
5224
|
return recommendedGotoOptions;
|
|
5169
5225
|
};
|
|
5170
5226
|
const launchContext = {
|
|
@@ -5219,9 +5275,8 @@ var DefaultLaunch = {
|
|
|
5219
5275
|
// src/internals/launch/cloak.js
|
|
5220
5276
|
var import_node_child_process2 = require("node:child_process");
|
|
5221
5277
|
var import_node_util = require("node:util");
|
|
5222
|
-
var
|
|
5278
|
+
var logger9 = createInternalLogger("Launch");
|
|
5223
5279
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process2.execFile);
|
|
5224
|
-
var REQUEST_HOOK_FLAG2 = Symbol("playwright-toolkit-cloak-request-hook");
|
|
5225
5280
|
var DEFAULT_CLOAK_CRAWLER_BASE_OPTIONS = Object.freeze({
|
|
5226
5281
|
maxConcurrency: 1,
|
|
5227
5282
|
maxRequestRetries: 0,
|
|
@@ -5249,9 +5304,9 @@ var loadCloakModule = async () => {
|
|
|
5249
5304
|
};
|
|
5250
5305
|
var buildCloakLaunchOptions = async (options = {}) => {
|
|
5251
5306
|
const { buildLaunchOptions } = await loadCloakModule();
|
|
5252
|
-
return await buildLaunchOptions(
|
|
5307
|
+
return await buildLaunchOptions(normalizeObject2(options));
|
|
5253
5308
|
};
|
|
5254
|
-
var
|
|
5309
|
+
var normalizeObject2 = (value) => {
|
|
5255
5310
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
5256
5311
|
return {};
|
|
5257
5312
|
}
|
|
@@ -5264,7 +5319,7 @@ var normalizeStringArray = (value) => {
|
|
|
5264
5319
|
return value.map((item) => String(item || "").trim()).filter(Boolean);
|
|
5265
5320
|
};
|
|
5266
5321
|
var resolveCloakProxy = (proxyConfiguration = {}) => {
|
|
5267
|
-
const config =
|
|
5322
|
+
const config = normalizeObject2(proxyConfiguration);
|
|
5268
5323
|
const proxyUrl = String(config.proxy_url || "").trim();
|
|
5269
5324
|
const enableProxy = typeof config.enable_proxy === "boolean" ? config.enable_proxy : proxyUrl !== "";
|
|
5270
5325
|
if (!enableProxy || !proxyUrl) {
|
|
@@ -5282,92 +5337,12 @@ var resolveCloakProxy = (proxyConfiguration = {}) => {
|
|
|
5282
5337
|
bypass: byPassDomains.join(",")
|
|
5283
5338
|
};
|
|
5284
5339
|
};
|
|
5285
|
-
var resolveProxyLaunchOptions2 = (proxyConfiguration = {}) => {
|
|
5286
|
-
const config = normalizeObject(proxyConfiguration);
|
|
5287
|
-
const proxyUrl = String(config.proxy_url || "").trim();
|
|
5288
|
-
const enableProxy = typeof config.enable_proxy === "boolean" ? config.enable_proxy : proxyUrl !== "";
|
|
5289
|
-
const byPassDomains = enableProxy && proxyUrl ? ByPass.normalizeByPassDomains(config.by_pass_domains) : [];
|
|
5290
|
-
return {
|
|
5291
|
-
byPassDomains,
|
|
5292
|
-
enableProxy,
|
|
5293
|
-
proxyUrl
|
|
5294
|
-
};
|
|
5295
|
-
};
|
|
5296
|
-
var buildMeteredProxy = ({ proxyConfiguration = {}, debugMode = false } = {}) => {
|
|
5297
|
-
const { byPassDomains, enableProxy, proxyUrl } = resolveProxyLaunchOptions2(proxyConfiguration);
|
|
5298
|
-
const byPassRules = ByPass.buildByPassDomainRules(byPassDomains);
|
|
5299
|
-
const proxyMeter = enableProxy && proxyUrl ? ProxyMeterRuntime.startProxyMeter({ proxyUrl, debugMode }) : null;
|
|
5300
|
-
const launchProxy = proxyMeter ? { server: proxyMeter.server } : null;
|
|
5301
|
-
if (launchProxy && byPassDomains.length > 0) {
|
|
5302
|
-
launchProxy.bypass = byPassDomains.join(",");
|
|
5303
|
-
}
|
|
5304
|
-
return {
|
|
5305
|
-
byPassDomains,
|
|
5306
|
-
byPassRules,
|
|
5307
|
-
enableProxy,
|
|
5308
|
-
proxyUrl,
|
|
5309
|
-
launchProxy
|
|
5310
|
-
};
|
|
5311
|
-
};
|
|
5312
|
-
var logProxyLaunchState = ({
|
|
5313
|
-
byPassDomains = [],
|
|
5314
|
-
debugMode = false,
|
|
5315
|
-
enableByPassLogger = false,
|
|
5316
|
-
enableProxy = false,
|
|
5317
|
-
launchProxy = null,
|
|
5318
|
-
proxyUrl = ""
|
|
5319
|
-
} = {}) => {
|
|
5320
|
-
if (!enableByPassLogger) return;
|
|
5321
|
-
if (launchProxy) {
|
|
5322
|
-
let upstreamLabel = "";
|
|
5323
|
-
try {
|
|
5324
|
-
const parsedProxyUrl = new URL(proxyUrl.includes("://") ? proxyUrl : `http://${proxyUrl}`);
|
|
5325
|
-
upstreamLabel = `${parsedProxyUrl.protocol}//${parsedProxyUrl.host}`;
|
|
5326
|
-
} catch {
|
|
5327
|
-
}
|
|
5328
|
-
logger8.info(
|
|
5329
|
-
`[\u4EE3\u7406\u5DF2\u542F\u7528] \u672C\u5730=${launchProxy.server} \u4E0A\u6E38=${upstreamLabel || "-"} \u76F4\u8FDE\u57DF\u540D=${byPassDomains.join(",")}`
|
|
5330
|
-
);
|
|
5331
|
-
logger8.info(`[\u6D41\u91CF\u89C2\u6D4B] \u9010\u8BF7\u6C42\u8C03\u8BD5=${Boolean(debugMode) ? "\u5F00\u542F" : "\u5173\u95ED"}\uFF08\u6C47\u603B\u59CB\u7EC8\u5F00\u542F\uFF09`);
|
|
5332
|
-
return;
|
|
5333
|
-
}
|
|
5334
|
-
if (enableProxy) {
|
|
5335
|
-
logger8.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=true \u4F46 proxy_url \u4E3A\u7A7A");
|
|
5336
|
-
} else if (proxyUrl) {
|
|
5337
|
-
logger8.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=false \u4E14 proxy_url \u5DF2\u914D\u7F6E");
|
|
5338
|
-
}
|
|
5339
|
-
logger8.info(`[\u6D41\u91CF\u89C2\u6D4B] \u9010\u8BF7\u6C42\u8C03\u8BD5=${Boolean(debugMode) ? "\u5F00\u542F" : "\u5173\u95ED"}\uFF08\u6C47\u603B\u59CB\u7EC8\u5F00\u542F\uFF09`);
|
|
5340
|
-
};
|
|
5341
|
-
var createProxyRequestHook = ({
|
|
5342
|
-
byPassDomains = [],
|
|
5343
|
-
byPassRules = [],
|
|
5344
|
-
enableByPassLogger = false,
|
|
5345
|
-
launchProxy = null
|
|
5346
|
-
} = {}) => {
|
|
5347
|
-
return (page) => {
|
|
5348
|
-
if (!page || typeof page.on !== "function" || page[REQUEST_HOOK_FLAG2]) {
|
|
5349
|
-
return;
|
|
5350
|
-
}
|
|
5351
|
-
page[REQUEST_HOOK_FLAG2] = true;
|
|
5352
|
-
page.on("request", (req) => {
|
|
5353
|
-
const requestUrl = req.url();
|
|
5354
|
-
const resourceType = req.resourceType();
|
|
5355
|
-
const matched = byPassDomains.length > 0 ? ByPass.findMatchedByPassRule(byPassRules, requestUrl) : null;
|
|
5356
|
-
if (launchProxy) {
|
|
5357
|
-
ProxyMeterRuntime.recordProxyMeterResourceType(requestUrl, resourceType);
|
|
5358
|
-
}
|
|
5359
|
-
if (!enableByPassLogger || byPassDomains.length === 0) return;
|
|
5360
|
-
if (!matched || !matched.rule) return;
|
|
5361
|
-
logger8.info(`[\u76F4\u8FDE\u547D\u4E2D] \u89C4\u5219=${matched.rule.pattern} \u57DF\u540D=${matched.hostname} \u8D44\u6E90\u7C7B\u578B=${resourceType} \u65B9\u6CD5=${req.method()} \u5730\u5740=${requestUrl}`);
|
|
5362
|
-
});
|
|
5363
|
-
};
|
|
5364
|
-
};
|
|
5365
5340
|
var extractFingerprintArg = (launchOptions = {}) => {
|
|
5366
5341
|
const args = Array.isArray(launchOptions?.args) ? launchOptions.args : [];
|
|
5367
5342
|
return args.find((value) => String(value || "").startsWith("--fingerprint=")) || "";
|
|
5368
5343
|
};
|
|
5369
5344
|
var createStableGotoHook = (recommendedGotoOptions = DEFAULT_CLOAK_GOTO_OPTIONS) => {
|
|
5370
|
-
const normalizedRecommendedGotoOptions =
|
|
5345
|
+
const normalizedRecommendedGotoOptions = normalizeObject2(recommendedGotoOptions);
|
|
5371
5346
|
const fallbackGotoOptions = Object.keys(normalizedRecommendedGotoOptions).length > 0 ? normalizedRecommendedGotoOptions : DEFAULT_CLOAK_GOTO_OPTIONS;
|
|
5372
5347
|
return async (_crawlingContext, gotoOptions = {}) => {
|
|
5373
5348
|
for (const [key, value] of Object.entries(fallbackGotoOptions)) {
|
|
@@ -5383,11 +5358,11 @@ var attachCloakHumanizeHook = ({
|
|
|
5383
5358
|
patchedBrowsers,
|
|
5384
5359
|
humanizeOptions = DEFAULT_CLOAK_HUMANIZE_OPTIONS
|
|
5385
5360
|
} = {}) => {
|
|
5386
|
-
const normalizedBrowserPoolOptions =
|
|
5361
|
+
const normalizedBrowserPoolOptions = normalizeObject2(browserPoolOptions);
|
|
5387
5362
|
const shouldHumanize = humanizeOptions !== false;
|
|
5388
5363
|
const normalizedHumanizeOptions = shouldHumanize ? {
|
|
5389
5364
|
...DEFAULT_CLOAK_HUMANIZE_OPTIONS,
|
|
5390
|
-
...
|
|
5365
|
+
...normalizeObject2(humanizeOptions)
|
|
5391
5366
|
} : null;
|
|
5392
5367
|
return {
|
|
5393
5368
|
...normalizedBrowserPoolOptions,
|
|
@@ -5436,7 +5411,7 @@ var forceTerminateBrowsersByFingerprintArg = async (fingerprintArg) => {
|
|
|
5436
5411
|
if (error?.code === 1 || error?.code === "ENOENT") {
|
|
5437
5412
|
return;
|
|
5438
5413
|
}
|
|
5439
|
-
|
|
5414
|
+
logger9.info(`\u5F3A\u5236\u5173\u95ED Cloak \u8FDB\u7A0B\u5931\u8D25\uFF08\u5FFD\u7565\uFF09: ${error?.message || String(error)}`);
|
|
5440
5415
|
});
|
|
5441
5416
|
};
|
|
5442
5417
|
var CloakLaunch = {
|
|
@@ -5470,7 +5445,7 @@ var CloakLaunch = {
|
|
|
5470
5445
|
return await buildCloakLaunchOptions(options);
|
|
5471
5446
|
},
|
|
5472
5447
|
async createPlaywrightCrawlerRuntime(options = {}) {
|
|
5473
|
-
const normalizedOptions =
|
|
5448
|
+
const normalizedOptions = normalizeObject2(options);
|
|
5474
5449
|
const {
|
|
5475
5450
|
proxyConfiguration = {},
|
|
5476
5451
|
log: logOptions = null,
|
|
@@ -5487,17 +5462,13 @@ var CloakLaunch = {
|
|
|
5487
5462
|
postNavigationHooks = [],
|
|
5488
5463
|
recommendedGotoOptions = DEFAULT_CLOAK_GOTO_OPTIONS
|
|
5489
5464
|
} = normalizedOptions;
|
|
5490
|
-
const normalizedCloakOptions =
|
|
5465
|
+
const normalizedCloakOptions = normalizeObject2(cloakOptions);
|
|
5491
5466
|
const activeBrowsers = /* @__PURE__ */ new Set();
|
|
5492
5467
|
const patchedBrowsers = /* @__PURE__ */ new WeakSet();
|
|
5493
5468
|
const defaultArgs = isRunningOnApify ? ["--no-sandbox", "--disable-setuid-sandbox"] : [];
|
|
5494
5469
|
const extraArgs = normalizeStringArray(normalizedCloakOptions.args);
|
|
5495
5470
|
const hasExplicitProxy = hasOwn(normalizedCloakOptions, "proxy");
|
|
5496
|
-
const proxyLaunchState = hasExplicitProxy ? {
|
|
5497
|
-
...resolveProxyLaunchOptions2(proxyConfiguration),
|
|
5498
|
-
byPassRules: [],
|
|
5499
|
-
launchProxy: null
|
|
5500
|
-
} : buildMeteredProxy({ proxyConfiguration, debugMode });
|
|
5471
|
+
const proxyLaunchState = hasExplicitProxy ? resolveLaunchTraffic({ proxyConfiguration, debugMode, useMeter: false }) : resolveLaunchTraffic({ proxyConfiguration, debugMode });
|
|
5501
5472
|
const proxy = hasExplicitProxy ? normalizedCloakOptions.proxy : proxyLaunchState.launchProxy;
|
|
5502
5473
|
const headless = hasOwn(normalizedCloakOptions, "headless") ? normalizedCloakOptions.headless : !runInHeadfulMode || isRunningOnApify;
|
|
5503
5474
|
const enableByPassLogger = Boolean(logOptions && logOptions.enable);
|
|
@@ -5510,30 +5481,27 @@ var CloakLaunch = {
|
|
|
5510
5481
|
const launchOptions = await buildCloakLaunchOptions(mergedCloakOptions);
|
|
5511
5482
|
const fingerprintArg = extractFingerprintArg(launchOptions);
|
|
5512
5483
|
const internalPreNavigationHook = createStableGotoHook(recommendedGotoOptions);
|
|
5513
|
-
const
|
|
5484
|
+
const trafficHook = createLaunchTrafficHook({
|
|
5514
5485
|
byPassDomains: proxyLaunchState.byPassDomains,
|
|
5515
5486
|
byPassRules: proxyLaunchState.byPassRules,
|
|
5516
|
-
enableByPassLogger,
|
|
5487
|
+
enabled: enableByPassLogger,
|
|
5517
5488
|
launchProxy: proxyLaunchState.launchProxy
|
|
5518
5489
|
});
|
|
5519
5490
|
const normalizedPreNavigationHooks = Array.isArray(preNavigationHooks) ? preNavigationHooks : [];
|
|
5520
5491
|
const normalizedPostNavigationHooks = Array.isArray(postNavigationHooks) ? postNavigationHooks : [];
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
enableByPassLogger
|
|
5528
|
-
});
|
|
5529
|
-
}
|
|
5492
|
+
logLaunchTraffic({
|
|
5493
|
+
...proxyLaunchState,
|
|
5494
|
+
debugMode,
|
|
5495
|
+
enabled: enableByPassLogger,
|
|
5496
|
+
explicitProxy: hasExplicitProxy
|
|
5497
|
+
});
|
|
5530
5498
|
const crawlerOptions = {
|
|
5531
5499
|
...DEFAULT_CLOAK_CRAWLER_BASE_OPTIONS,
|
|
5532
|
-
...
|
|
5500
|
+
...normalizeObject2(crawlerBaseOptions),
|
|
5533
5501
|
headless,
|
|
5534
5502
|
launchContext: {
|
|
5535
5503
|
useIncognitoPages: true,
|
|
5536
|
-
...
|
|
5504
|
+
...normalizeObject2(launchContext),
|
|
5537
5505
|
...launcher ? { launcher } : {},
|
|
5538
5506
|
launchOptions
|
|
5539
5507
|
},
|
|
@@ -5545,7 +5513,7 @@ var CloakLaunch = {
|
|
|
5545
5513
|
}),
|
|
5546
5514
|
preNavigationHooks: [
|
|
5547
5515
|
async (crawlingContext, gotoOptions = {}) => {
|
|
5548
|
-
|
|
5516
|
+
trafficHook(crawlingContext?.page);
|
|
5549
5517
|
await internalPreNavigationHook(crawlingContext, gotoOptions);
|
|
5550
5518
|
},
|
|
5551
5519
|
...normalizedPreNavigationHooks
|
|
@@ -5584,7 +5552,7 @@ var Launch = withModeReflect("Launch", launchStrategies);
|
|
|
5584
5552
|
// src/live-view.js
|
|
5585
5553
|
var import_express = __toESM(require("express"), 1);
|
|
5586
5554
|
var import_apify = require("apify");
|
|
5587
|
-
var
|
|
5555
|
+
var logger10 = createInternalLogger("LiveView");
|
|
5588
5556
|
async function startLiveViewServer(liveViewKey) {
|
|
5589
5557
|
const app = (0, import_express.default)();
|
|
5590
5558
|
app.get("/", async (req, res) => {
|
|
@@ -5609,13 +5577,13 @@ async function startLiveViewServer(liveViewKey) {
|
|
|
5609
5577
|
</html>
|
|
5610
5578
|
`);
|
|
5611
5579
|
} catch (error) {
|
|
5612
|
-
|
|
5580
|
+
logger10.fail("Live View Server", error);
|
|
5613
5581
|
res.status(500).send(`\u65E0\u6CD5\u52A0\u8F7D\u5C4F\u5E55\u622A\u56FE: ${error.message}`);
|
|
5614
5582
|
}
|
|
5615
5583
|
});
|
|
5616
5584
|
const port = process.env.APIFY_CONTAINER_PORT || 4321;
|
|
5617
5585
|
app.listen(port, () => {
|
|
5618
|
-
|
|
5586
|
+
logger10.success("startLiveViewServer", `\u76D1\u542C\u7AEF\u53E3 ${port}`);
|
|
5619
5587
|
});
|
|
5620
5588
|
}
|
|
5621
5589
|
async function takeLiveScreenshot(liveViewKey, page, logMessage) {
|
|
@@ -5623,10 +5591,10 @@ async function takeLiveScreenshot(liveViewKey, page, logMessage) {
|
|
|
5623
5591
|
const buffer = await capturePageScreenshot(page, { type: "png" });
|
|
5624
5592
|
await import_apify.Actor.setValue(liveViewKey, buffer, { contentType: "image/png" });
|
|
5625
5593
|
if (logMessage) {
|
|
5626
|
-
|
|
5594
|
+
logger10.info(`(\u622A\u56FE): ${logMessage}`);
|
|
5627
5595
|
}
|
|
5628
5596
|
} catch (e) {
|
|
5629
|
-
|
|
5597
|
+
logger10.warn(`\u65E0\u6CD5\u6355\u83B7 Live View \u5C4F\u5E55\u622A\u56FE: ${e.message}`);
|
|
5630
5598
|
}
|
|
5631
5599
|
}
|
|
5632
5600
|
var useLiveView = (liveViewKey = PresetOfLiveViewKey) => {
|
|
@@ -5735,7 +5703,7 @@ var dragCaptchaAction = async (page, sourceLocator, targetLocator, options = {})
|
|
|
5735
5703
|
};
|
|
5736
5704
|
|
|
5737
5705
|
// src/internals/captcha/bytedance.js
|
|
5738
|
-
var
|
|
5706
|
+
var logger11 = createInternalLogger("Captcha");
|
|
5739
5707
|
var DEFAULT_BYTEDANCE_CAPTCHA_OPTIONS = Object.freeze({
|
|
5740
5708
|
apiType: "31234",
|
|
5741
5709
|
maxRetries: 3,
|
|
@@ -5867,7 +5835,7 @@ var collectCaptchaDebugInfo = async (page, frame, iframeLocator, attempt, phase,
|
|
|
5867
5835
|
}
|
|
5868
5836
|
await (0, import_promises.writeFile)(infoPath, JSON.stringify(payload, null, 2), "utf8");
|
|
5869
5837
|
}
|
|
5870
|
-
|
|
5838
|
+
logger11.info(`\u5DF2\u5199\u51FA\u9A8C\u8BC1\u7801\u8C03\u8BD5\u4EA7\u7269\uFF1A${debugDir}`);
|
|
5871
5839
|
};
|
|
5872
5840
|
var maybeCollectCaptchaDebugInfo = async (page, frame, iframeLocator, attempt, phase, options, extra = null) => {
|
|
5873
5841
|
if (!options.debugArtifacts) {
|
|
@@ -5904,14 +5872,14 @@ var getVerifycenterCaptchaContext = async (page, options) => {
|
|
|
5904
5872
|
if (!isContainerVisible) {
|
|
5905
5873
|
return null;
|
|
5906
5874
|
}
|
|
5907
|
-
|
|
5875
|
+
logger11.info("\u68C0\u6D4B\u5230\u9A8C\u8BC1\u7801\u5BB9\u5668\uFF0C\u5F00\u59CB\u7B49\u5F85 iframe \u52A0\u8F7D\u3002");
|
|
5908
5876
|
let iframeLocator = page.locator(options.iframeSelector).first();
|
|
5909
5877
|
let isIframeVisible = await waitForVisible(
|
|
5910
5878
|
iframeLocator,
|
|
5911
5879
|
options.iframeVisibleTimeoutMs
|
|
5912
5880
|
);
|
|
5913
5881
|
if (!isIframeVisible) {
|
|
5914
|
-
|
|
5882
|
+
logger11.warn("\u672A\u5728\u9884\u671F\u9009\u62E9\u5668\u4E2D\u627E\u5230 verifycenter iframe\uFF0C\u5C1D\u8BD5\u5BB9\u5668\u5185\u4EFB\u610F iframe\u3002");
|
|
5915
5883
|
iframeLocator = captchaContainer.locator(options.iframeFallbackSelector).first();
|
|
5916
5884
|
isIframeVisible = await waitForVisible(
|
|
5917
5885
|
iframeLocator,
|
|
@@ -5921,7 +5889,7 @@ var getVerifycenterCaptchaContext = async (page, options) => {
|
|
|
5921
5889
|
if (!isIframeVisible) {
|
|
5922
5890
|
throw new Error("verifycenter iframe not found inside captcha container.");
|
|
5923
5891
|
}
|
|
5924
|
-
|
|
5892
|
+
logger11.info("\u9A8C\u8BC1\u7801 iframe \u5DF2\u53EF\u89C1\uFF0C\u5F00\u59CB\u89E3\u6790\u5185\u5BB9 frame\u3002");
|
|
5925
5893
|
const frame = await resolveContentFrame(page, iframeLocator, options);
|
|
5926
5894
|
if (!frame) {
|
|
5927
5895
|
throw new Error("Failed to resolve verifycenter iframe content frame.");
|
|
@@ -6037,11 +6005,11 @@ var refreshCaptcha = async (page, frame, options) => {
|
|
|
6037
6005
|
const clicked = await clickCaptchaAction(frame, options.refreshTexts, {
|
|
6038
6006
|
...options,
|
|
6039
6007
|
page,
|
|
6040
|
-
logger:
|
|
6008
|
+
logger: logger11,
|
|
6041
6009
|
forceMouse: true
|
|
6042
6010
|
}).catch(() => false);
|
|
6043
6011
|
if (!clicked) {
|
|
6044
|
-
|
|
6012
|
+
logger11.warn("Refresh button not found.");
|
|
6045
6013
|
return false;
|
|
6046
6014
|
}
|
|
6047
6015
|
await page.waitForTimeout(options.refreshWaitMs);
|
|
@@ -6072,24 +6040,24 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
|
|
|
6072
6040
|
const hasGuideMaskVisible = options.guideMaskSelector ? await frame.locator(options.guideMaskSelector).first().isVisible({ timeout: options.loadingIndicatorVisibleTimeoutMs }).catch(() => false) : false;
|
|
6073
6041
|
hasSeenGuideMask = hasSeenGuideMask || hasGuideMaskVisible;
|
|
6074
6042
|
if (hasGuideMaskVisible && !hasLoggedGuideMask) {
|
|
6075
|
-
|
|
6043
|
+
logger11.info("\u68C0\u6D4B\u5230\u9A8C\u8BC1\u7801\u64CD\u4F5C\u5F15\u5BFC\u5C42\uFF0C\u7B49\u5F85\u5176\u6D88\u5931\u540E\u518D\u5F00\u59CB\u8BC6\u522B\u3002");
|
|
6076
6044
|
hasLoggedGuideMask = true;
|
|
6077
6045
|
}
|
|
6078
6046
|
if (!isLoadingVisible && hasVisibleSourceImage && hasVisibleDropTarget && !hasGuideMaskVisible) {
|
|
6079
|
-
|
|
6047
|
+
logger11.info(
|
|
6080
6048
|
hasSeenGuideMask ? "\u9A8C\u8BC1\u7801\u56FE\u7247\u548C\u62D6\u62FD\u533A\u57DF\u5DF2\u5C31\u7EEA\uFF0C\u5F15\u5BFC\u5C42\u5DF2\u6D88\u5931\u3002" : hasSeenLoading ? "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u52A0\u8F7D\u5B8C\u6210\u3002" : "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u5C31\u7EEA\u3002"
|
|
6081
6049
|
);
|
|
6082
6050
|
return;
|
|
6083
6051
|
}
|
|
6084
6052
|
if (hasErrorTextVisible) {
|
|
6085
|
-
|
|
6053
|
+
logger11.warn("\u9A8C\u8BC1\u7801\u9762\u677F\u51FA\u73B0\u7F51\u7EDC\u5F02\u5E38\u6587\u6848\uFF0C\u5C1D\u8BD5\u7ACB\u5373\u5237\u65B0\u9898\u76EE\u3002");
|
|
6086
6054
|
await refreshCaptcha(page, frame, options);
|
|
6087
6055
|
refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
|
|
6088
6056
|
hasSeenLoading = false;
|
|
6089
6057
|
continue;
|
|
6090
6058
|
}
|
|
6091
6059
|
if ((!hasVisibleSourceImage || !hasVisibleDropTarget) && Date.now() >= refreshDeadline) {
|
|
6092
|
-
|
|
6060
|
+
logger11.warn(`\u9A8C\u8BC1\u7801\u9898\u76EE\u8D85\u8FC7 ${options.challengeReadyRefreshTimeoutMs}ms \u4ECD\u672A\u51C6\u5907\u597D\uFF0C\u5C1D\u8BD5\u5237\u65B0\u9898\u76EE\u3002`);
|
|
6093
6061
|
await refreshCaptcha(page, frame, options);
|
|
6094
6062
|
refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
|
|
6095
6063
|
hasSeenLoading = false;
|
|
@@ -6137,7 +6105,7 @@ var dragPromptCaptchaImage = async (page, frame, iframeLocator, sourceLocator, d
|
|
|
6137
6105
|
accepted
|
|
6138
6106
|
};
|
|
6139
6107
|
dragAttempts.push(attemptInfo);
|
|
6140
|
-
|
|
6108
|
+
logger11.info(
|
|
6141
6109
|
`\u9A8C\u8BC1\u7801\u62D6\u62FD\u7B2C ${visualIndex + 1} \u5F20\uFF0C\u65B9\u6848 ${plan.name}\uFF0Cbadge ${baselineState.badgeCount} -> ${afterState.badgeCount}\uFF0Cselected ${baselineState.selectedCount} -> ${afterState.selectedCount}`
|
|
6142
6110
|
);
|
|
6143
6111
|
if (accepted) {
|
|
@@ -6155,7 +6123,7 @@ var dragPromptCaptchaImage = async (page, frame, iframeLocator, sourceLocator, d
|
|
|
6155
6123
|
dragAttempts,
|
|
6156
6124
|
finalState: await readPromptCaptchaState(frame, options)
|
|
6157
6125
|
}).catch((error) => {
|
|
6158
|
-
|
|
6126
|
+
logger11.warn(`\u9A8C\u8BC1\u7801\u62D6\u62FD\u5931\u8D25\u8C03\u8BD5\u6293\u53D6\u5931\u8D25\uFF1A${error?.message || error}`);
|
|
6159
6127
|
});
|
|
6160
6128
|
return {
|
|
6161
6129
|
accepted: false,
|
|
@@ -6172,16 +6140,16 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6172
6140
|
...options
|
|
6173
6141
|
};
|
|
6174
6142
|
if (!config.token) {
|
|
6175
|
-
|
|
6143
|
+
logger11.warn("\u7F3A\u5C11\u9A8C\u8BC1\u7801 token\uFF0C\u8DF3\u8FC7\u81EA\u52A8\u8BC6\u522B\u3002");
|
|
6176
6144
|
return false;
|
|
6177
6145
|
}
|
|
6178
|
-
|
|
6146
|
+
logger11.info("\u5F53\u524D\u4F7F\u7528\u672Ctool\u2014\u2014\u6D4B\u8BD5\u7248\u672C");
|
|
6179
6147
|
for (let attempt = 1; attempt <= config.maxRetries; attempt += 1) {
|
|
6180
|
-
|
|
6148
|
+
logger11.info(`\u5F00\u59CB\u7B2C ${attempt}/${config.maxRetries} \u6B21 verifycenter \u9A8C\u8BC1\u7801\u8BC6\u522B\u3002`);
|
|
6181
6149
|
try {
|
|
6182
6150
|
const captchaContext = await getVerifycenterCaptchaContext(page, config);
|
|
6183
6151
|
if (!captchaContext) {
|
|
6184
|
-
|
|
6152
|
+
logger11.info("Captcha container is not visible anymore.");
|
|
6185
6153
|
return true;
|
|
6186
6154
|
}
|
|
6187
6155
|
const { iframeLocator, frame } = captchaContext;
|
|
@@ -6194,7 +6162,7 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6194
6162
|
"ready",
|
|
6195
6163
|
config
|
|
6196
6164
|
).catch((error) => {
|
|
6197
|
-
|
|
6165
|
+
logger11.warn(`\u9A8C\u8BC1\u7801\u8C03\u8BD5\u6293\u53D6\u5931\u8D25\uFF1A${error?.message || error}`);
|
|
6198
6166
|
});
|
|
6199
6167
|
await page.waitForTimeout(config.recognitionDelayMs);
|
|
6200
6168
|
const screenshotBuffer = await iframeLocator.screenshot();
|
|
@@ -6206,16 +6174,16 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6206
6174
|
});
|
|
6207
6175
|
const serialNumbers = extractCaptchaSerialNumbers(apiResponse);
|
|
6208
6176
|
if (apiResponse?.code !== config.recognitionSuccessCode || serialNumbers.length === 0) {
|
|
6209
|
-
|
|
6177
|
+
logger11.warn(
|
|
6210
6178
|
`\u9A8C\u8BC1\u7801\u8BC6\u522B\u5931\u8D25\u3002code=${apiResponse?.code}, msg=${apiResponse?.msg || "unknown"}`
|
|
6211
6179
|
);
|
|
6212
6180
|
await refreshCaptcha(page, frame, config);
|
|
6213
6181
|
continue;
|
|
6214
6182
|
}
|
|
6215
|
-
|
|
6183
|
+
logger11.info(`\u9A8C\u8BC1\u7801\u8BC6\u522B\u6210\u529F\uFF0C\u5E8F\u53F7\uFF1A${serialNumbers.join(", ")}`);
|
|
6216
6184
|
const dropTarget = await findCaptchaDropTarget(frame, config);
|
|
6217
6185
|
if (!dropTarget) {
|
|
6218
|
-
|
|
6186
|
+
logger11.warn("\u672A\u627E\u5230\u9A8C\u8BC1\u7801\u62D6\u62FD\u76EE\u6807\u533A\u57DF\u3002");
|
|
6219
6187
|
await refreshCaptcha(page, frame, config);
|
|
6220
6188
|
continue;
|
|
6221
6189
|
}
|
|
@@ -6226,7 +6194,7 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6226
6194
|
`Captcha image indexes could not be normalized. raw=${serialNumbers.join(", ")}, count=${orderedSourceImages.length}`
|
|
6227
6195
|
);
|
|
6228
6196
|
}
|
|
6229
|
-
|
|
6197
|
+
logger11.info(`\u9A8C\u8BC1\u7801\u89C6\u89C9\u4F4D\u5E8F\u6620\u5C04\uFF1A${normalizedIndexes.map((index) => index + 1).join(", ")}`);
|
|
6230
6198
|
for (const imageIndex of normalizedIndexes) {
|
|
6231
6199
|
if (imageIndex < 0 || imageIndex >= orderedSourceImages.length) {
|
|
6232
6200
|
throw new Error(
|
|
@@ -6258,52 +6226,52 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6258
6226
|
}
|
|
6259
6227
|
}
|
|
6260
6228
|
const beforeSubmitState = await readPromptCaptchaState(frame, config);
|
|
6261
|
-
|
|
6229
|
+
logger11.info(
|
|
6262
6230
|
`\u63D0\u4EA4\u524D\u9A8C\u8BC1\u7801\u72B6\u6001\uFF1Abadge=${beforeSubmitState.badgeCount}, selected=${beforeSubmitState.selectedCount}, submitDisabled=${beforeSubmitState.submitDisabled}`
|
|
6263
6231
|
);
|
|
6264
6232
|
const submitted = await clickCaptchaAction(frame, config.submitTexts, {
|
|
6265
6233
|
...config,
|
|
6266
6234
|
page,
|
|
6267
|
-
logger:
|
|
6235
|
+
logger: logger11,
|
|
6268
6236
|
forceMouse: true,
|
|
6269
6237
|
actionVisibleTimeoutMs: config.submitReadyTimeoutMs
|
|
6270
6238
|
}).catch(() => false);
|
|
6271
6239
|
if (!submitted) {
|
|
6272
|
-
|
|
6240
|
+
logger11.warn("\u672A\u627E\u5230\u63D0\u4EA4\u6309\u94AE\uFF0C\u53EF\u80FD\u4F1A\u81EA\u52A8\u63D0\u4EA4\u3002");
|
|
6273
6241
|
}
|
|
6274
6242
|
await page.waitForTimeout(config.submitWaitMs);
|
|
6275
6243
|
const afterSubmitState = await readPromptCaptchaState(frame, config);
|
|
6276
|
-
|
|
6244
|
+
logger11.info(
|
|
6277
6245
|
`\u63D0\u4EA4\u540E\u9A8C\u8BC1\u7801\u72B6\u6001\uFF1Abadge=${afterSubmitState.badgeCount}, selected=${afterSubmitState.selectedCount}, submitDisabled=${afterSubmitState.submitDisabled}`
|
|
6278
6246
|
);
|
|
6279
6247
|
const stillVisible = await iframeLocator.isVisible({ timeout: config.containerVisibleTimeoutMs }).catch(() => false);
|
|
6280
6248
|
if (!stillVisible) {
|
|
6281
|
-
|
|
6249
|
+
logger11.info("\u9A8C\u8BC1\u7801\u8BC6\u522B\u5E76\u63D0\u4EA4\u6210\u529F\u3002");
|
|
6282
6250
|
return true;
|
|
6283
6251
|
}
|
|
6284
6252
|
await maybeCollectCaptchaDebugInfo(page, frame, iframeLocator, attempt, "submit-still-visible", config, {
|
|
6285
6253
|
beforeSubmitState,
|
|
6286
6254
|
afterSubmitState
|
|
6287
6255
|
}).catch((error) => {
|
|
6288
|
-
|
|
6256
|
+
logger11.warn(`\u63D0\u4EA4\u540E\u9A8C\u8BC1\u7801\u8C03\u8BD5\u6293\u53D6\u5931\u8D25\uFF1A${error?.message || error}`);
|
|
6289
6257
|
});
|
|
6290
|
-
|
|
6258
|
+
logger11.warn("\u63D0\u4EA4\u540E\u9A8C\u8BC1\u7801 iframe \u4ECD\u7136\u53EF\u89C1\uFF0C\u51C6\u5907\u5237\u65B0\u540E\u91CD\u8BD5\u3002");
|
|
6291
6259
|
await page.waitForTimeout(2e3);
|
|
6292
6260
|
await refreshCaptcha(page, frame, config);
|
|
6293
6261
|
} catch (error) {
|
|
6294
|
-
|
|
6262
|
+
logger11.error(`\u7B2C ${attempt}/${config.maxRetries} \u6B21\u9A8C\u8BC1\u7801\u8BC6\u522B\u5931\u8D25\uFF1A${error?.message || error}`);
|
|
6295
6263
|
}
|
|
6296
6264
|
if (attempt < config.maxRetries) {
|
|
6297
6265
|
await page.waitForTimeout(config.retryDelayBaseMs + attempt * config.retryDelayStepMs);
|
|
6298
6266
|
}
|
|
6299
6267
|
}
|
|
6300
|
-
|
|
6268
|
+
logger11.error(`\u91CD\u8BD5 ${config.maxRetries} \u6B21\u540E\uFF0C\u9A8C\u8BC1\u7801\u4ECD\u672A\u8BC6\u522B\u6210\u529F\u3002`);
|
|
6301
6269
|
return false;
|
|
6302
6270
|
}
|
|
6303
6271
|
var sloveCaptcha = solveCaptcha;
|
|
6304
6272
|
|
|
6305
6273
|
// src/chaptcha.js
|
|
6306
|
-
var
|
|
6274
|
+
var logger12 = createInternalLogger("Captcha");
|
|
6307
6275
|
var DEFAULT_CAPTCHA_RECOGNITION_OPTIONS = Object.freeze({
|
|
6308
6276
|
token: "eKJvBfwfN0YRav0-VD_44E2VBSfm7l0YtddUQ7cFySI",
|
|
6309
6277
|
apiUrl: "https://api.jfbym.com/api/YmServer/customApi"
|
|
@@ -6390,7 +6358,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
6390
6358
|
};
|
|
6391
6359
|
})();
|
|
6392
6360
|
}, { selector: domSelector, callbackName: exposedFunctionName, cleanerName });
|
|
6393
|
-
|
|
6361
|
+
logger12.success("useCaptchaMonitor", `DOM \u76D1\u63A7\u5DF2\u542F\u7528\uFF1A${domSelector}`);
|
|
6394
6362
|
cleanupFns.push(async () => {
|
|
6395
6363
|
try {
|
|
6396
6364
|
await page.evaluate((name) => {
|
|
@@ -6414,14 +6382,14 @@ function useCaptchaMonitor(page, options) {
|
|
|
6414
6382
|
}
|
|
6415
6383
|
};
|
|
6416
6384
|
page.on("framenavigated", frameHandler);
|
|
6417
|
-
|
|
6385
|
+
logger12.success("useCaptchaMonitor", `URL \u76D1\u63A7\u5DF2\u542F\u7528\uFF1A${urlPattern}`);
|
|
6418
6386
|
cleanupFns.push(async () => {
|
|
6419
6387
|
page.off("framenavigated", frameHandler);
|
|
6420
6388
|
});
|
|
6421
6389
|
}
|
|
6422
6390
|
return {
|
|
6423
6391
|
stop: async () => {
|
|
6424
|
-
|
|
6392
|
+
logger12.info("\u6B63\u5728\u505C\u6B62\u9A8C\u8BC1\u7801\u76D1\u63A7...");
|
|
6425
6393
|
for (const fn of cleanupFns) {
|
|
6426
6394
|
await fn();
|
|
6427
6395
|
}
|
|
@@ -6460,7 +6428,7 @@ async function solveCaptchaWithStrategy(strategyName, page, options = {}) {
|
|
|
6460
6428
|
);
|
|
6461
6429
|
return strategy.sloveCaptcha(page, resolvedOptions, {
|
|
6462
6430
|
callCaptchaRecognitionApi,
|
|
6463
|
-
logger:
|
|
6431
|
+
logger: logger12
|
|
6464
6432
|
});
|
|
6465
6433
|
}
|
|
6466
6434
|
var Captcha = {
|
|
@@ -6471,7 +6439,7 @@ var Captcha = {
|
|
|
6471
6439
|
// src/mutation.js
|
|
6472
6440
|
var import_node_crypto = require("node:crypto");
|
|
6473
6441
|
var import_uuid2 = require("uuid");
|
|
6474
|
-
var
|
|
6442
|
+
var logger13 = createInternalLogger("Mutation");
|
|
6475
6443
|
var MUTATION_MONITOR_MODE = Object.freeze({
|
|
6476
6444
|
Added: "added",
|
|
6477
6445
|
Changed: "changed",
|
|
@@ -6504,14 +6472,14 @@ var Mutation = {
|
|
|
6504
6472
|
const stableTime = options.stableTime ?? 5 * 1e3;
|
|
6505
6473
|
const timeout = options.timeout ?? 120 * 1e3;
|
|
6506
6474
|
const onMutation = options.onMutation;
|
|
6507
|
-
|
|
6475
|
+
logger13.start("waitForStable", `\u76D1\u63A7 ${selectorList.length} \u4E2A\u9009\u62E9\u5668, \u7A33\u5B9A\u65F6\u95F4=${stableTime}ms`);
|
|
6508
6476
|
if (initialTimeout > 0) {
|
|
6509
6477
|
const selectorQuery = selectorList.join(",");
|
|
6510
6478
|
try {
|
|
6511
6479
|
await page.waitForSelector(selectorQuery, { timeout: initialTimeout });
|
|
6512
|
-
|
|
6480
|
+
logger13.info(`waitForStable \u5DF2\u68C0\u6D4B\u5230\u5143\u7D20: ${selectorQuery}`);
|
|
6513
6481
|
} catch (e) {
|
|
6514
|
-
|
|
6482
|
+
logger13.warning(`waitForStable \u521D\u59CB\u7B49\u5F85\u8D85\u65F6 (${initialTimeout}ms): ${selectorQuery}`);
|
|
6515
6483
|
throw e;
|
|
6516
6484
|
}
|
|
6517
6485
|
}
|
|
@@ -6527,7 +6495,7 @@ var Mutation = {
|
|
|
6527
6495
|
return "__CONTINUE__";
|
|
6528
6496
|
}
|
|
6529
6497
|
});
|
|
6530
|
-
|
|
6498
|
+
logger13.info("waitForStable \u5DF2\u542F\u7528 onMutation \u56DE\u8C03");
|
|
6531
6499
|
} catch (e) {
|
|
6532
6500
|
}
|
|
6533
6501
|
}
|
|
@@ -6642,9 +6610,9 @@ var Mutation = {
|
|
|
6642
6610
|
{ selectorList, stableTime, timeout, callbackName, hasCallback: !!onMutation }
|
|
6643
6611
|
);
|
|
6644
6612
|
if (result.mutationCount === 0 && result.stableTime === 0) {
|
|
6645
|
-
|
|
6613
|
+
logger13.warning("waitForStable \u672A\u627E\u5230\u53EF\u76D1\u63A7\u7684\u5143\u7D20");
|
|
6646
6614
|
}
|
|
6647
|
-
|
|
6615
|
+
logger13.success("waitForStable", `DOM \u7A33\u5B9A, \u603B\u5171 ${result.mutationCount} \u6B21\u53D8\u5316${result.wasPaused ? ", \u66FE\u6682\u505C\u8BA1\u65F6" : ""}`);
|
|
6648
6616
|
return result;
|
|
6649
6617
|
},
|
|
6650
6618
|
/**
|
|
@@ -6816,22 +6784,22 @@ var Mutation = {
|
|
|
6816
6784
|
return "__CONTINUE__";
|
|
6817
6785
|
}
|
|
6818
6786
|
};
|
|
6819
|
-
|
|
6787
|
+
logger13.start(
|
|
6820
6788
|
"waitForStableAcrossRoots",
|
|
6821
6789
|
`\u76D1\u63A7 ${selectorList.length} \u4E2A\u9009\u62E9\u5668(\u8DE8 root), \u7A33\u5B9A\u65F6\u95F4=${waitForStableTime}ms`
|
|
6822
6790
|
);
|
|
6823
6791
|
if (initialTimeout > 0) {
|
|
6824
6792
|
try {
|
|
6825
6793
|
await page.waitForSelector(selectorQuery, { timeout: initialTimeout });
|
|
6826
|
-
|
|
6794
|
+
logger13.info(`waitForStableAcrossRoots \u5DF2\u68C0\u6D4B\u5230\u5143\u7D20: ${selectorQuery}`);
|
|
6827
6795
|
} catch (e) {
|
|
6828
|
-
|
|
6796
|
+
logger13.warning(`waitForStableAcrossRoots \u521D\u59CB\u7B49\u5F85\u8D85\u65F6 (${initialTimeout}ms): ${selectorQuery}`);
|
|
6829
6797
|
throw e;
|
|
6830
6798
|
}
|
|
6831
6799
|
}
|
|
6832
6800
|
let state2 = await buildState();
|
|
6833
6801
|
if (!state2?.hasMatched) {
|
|
6834
|
-
|
|
6802
|
+
logger13.warning("waitForStableAcrossRoots \u672A\u627E\u5230\u53EF\u76D1\u63A7\u7684\u5143\u7D20");
|
|
6835
6803
|
return { mutationCount: 0, stableTime: 0, wasPaused: false };
|
|
6836
6804
|
}
|
|
6837
6805
|
let mutationCount = 0;
|
|
@@ -6868,7 +6836,7 @@ var Mutation = {
|
|
|
6868
6836
|
if (lastState.snapshotKey !== lastSnapshotKey) {
|
|
6869
6837
|
lastSnapshotKey = lastState.snapshotKey;
|
|
6870
6838
|
mutationCount += 1;
|
|
6871
|
-
|
|
6839
|
+
logger13.info(
|
|
6872
6840
|
`waitForStableAcrossRoots \u53D8\u5316#${mutationCount}, len=${lastState.snapshotLength}, path=${lastState.primaryPath || "unknown"}, preview="${truncate(lastState.text, 120)}"`
|
|
6873
6841
|
);
|
|
6874
6842
|
const signal = await invokeMutationCallback({
|
|
@@ -6881,7 +6849,7 @@ var Mutation = {
|
|
|
6881
6849
|
continue;
|
|
6882
6850
|
}
|
|
6883
6851
|
if (!isPaused && stableSince > 0 && Date.now() - stableSince >= waitForStableTime) {
|
|
6884
|
-
|
|
6852
|
+
logger13.success("waitForStableAcrossRoots", `DOM \u7A33\u5B9A, \u603B\u5171 ${mutationCount} \u6B21\u53D8\u5316${wasPaused ? ", \u66FE\u6682\u505C\u8BA1\u65F6" : ""}`);
|
|
6885
6853
|
return {
|
|
6886
6854
|
mutationCount,
|
|
6887
6855
|
stableTime: waitForStableTime,
|
|
@@ -6908,7 +6876,7 @@ var Mutation = {
|
|
|
6908
6876
|
const onMutation = options.onMutation;
|
|
6909
6877
|
const rawMode = String(options.mode || MUTATION_MONITOR_MODE.Added).toLowerCase();
|
|
6910
6878
|
const mode = [MUTATION_MONITOR_MODE.Added, MUTATION_MONITOR_MODE.Changed, MUTATION_MONITOR_MODE.All].includes(rawMode) ? rawMode : MUTATION_MONITOR_MODE.Added;
|
|
6911
|
-
|
|
6879
|
+
logger13.start("useMonitor", `\u76D1\u63A7 ${selectorList.length} \u4E2A\u9009\u62E9\u5668, mode=${mode}`);
|
|
6912
6880
|
const monitorKey = generateKey("pk_mon");
|
|
6913
6881
|
const callbackName = generateKey("pk_mon_cb");
|
|
6914
6882
|
const cleanerName = generateKey("pk_mon_clean");
|
|
@@ -7051,7 +7019,7 @@ var Mutation = {
|
|
|
7051
7019
|
return total;
|
|
7052
7020
|
};
|
|
7053
7021
|
}, { selectorList, monitorKey, callbackName, cleanerName, hasCallback: !!onMutation, mode });
|
|
7054
|
-
|
|
7022
|
+
logger13.success("useMonitor", "\u76D1\u63A7\u5668\u5DF2\u542F\u52A8");
|
|
7055
7023
|
return {
|
|
7056
7024
|
stop: async () => {
|
|
7057
7025
|
let totalMutations = 0;
|
|
@@ -7064,7 +7032,7 @@ var Mutation = {
|
|
|
7064
7032
|
}, cleanerName);
|
|
7065
7033
|
} catch (e) {
|
|
7066
7034
|
}
|
|
7067
|
-
|
|
7035
|
+
logger13.success("useMonitor.stop", `\u76D1\u63A7\u5DF2\u505C\u6B62, \u5171 ${totalMutations} \u6B21\u53D8\u5316`);
|
|
7068
7036
|
return { totalMutations };
|
|
7069
7037
|
}
|
|
7070
7038
|
};
|
|
@@ -7933,7 +7901,7 @@ var createTemplateLogger = (baseLogger = createBaseLogger()) => {
|
|
|
7933
7901
|
};
|
|
7934
7902
|
var getDefaultBaseLogger = () => createBaseLogger("");
|
|
7935
7903
|
var Logger = {
|
|
7936
|
-
setLogger: (
|
|
7904
|
+
setLogger: (logger17) => setDefaultLogger(logger17),
|
|
7937
7905
|
info: (message) => getDefaultBaseLogger().info(message),
|
|
7938
7906
|
success: (message) => getDefaultBaseLogger().success(message),
|
|
7939
7907
|
warning: (message) => getDefaultBaseLogger().warning(message),
|
|
@@ -7941,8 +7909,8 @@ var Logger = {
|
|
|
7941
7909
|
error: (message) => getDefaultBaseLogger().error(message),
|
|
7942
7910
|
debug: (message) => getDefaultBaseLogger().debug(message),
|
|
7943
7911
|
start: (message) => getDefaultBaseLogger().start(message),
|
|
7944
|
-
useTemplate: (
|
|
7945
|
-
if (
|
|
7912
|
+
useTemplate: (logger17) => {
|
|
7913
|
+
if (logger17) return createTemplateLogger(createBaseLogger("", logger17));
|
|
7946
7914
|
return createTemplateLogger();
|
|
7947
7915
|
}
|
|
7948
7916
|
};
|
|
@@ -8016,7 +7984,7 @@ var LOCATION_NETWORK_SUFFIX_PATTERNS = [
|
|
|
8016
7984
|
];
|
|
8017
7985
|
var cachedStripLogoSrcPromise = null;
|
|
8018
7986
|
var cachedEnrichmentByContext = /* @__PURE__ */ new WeakMap();
|
|
8019
|
-
var
|
|
7987
|
+
var logger14 = createInternalLogger("Watermarkify");
|
|
8020
7988
|
var normalizeText = (value) => String(value || "").trim();
|
|
8021
7989
|
var toInline = (value, maxLen = 200) => {
|
|
8022
7990
|
const text = normalizeText(value);
|
|
@@ -8258,9 +8226,9 @@ var resolveWithCustomResolver = async (page, baseMeta, options = {}) => {
|
|
|
8258
8226
|
location: toInline(resolved.location, 80)
|
|
8259
8227
|
};
|
|
8260
8228
|
if (enrichment.ip || enrichment.location) {
|
|
8261
|
-
|
|
8229
|
+
logger14.info(`\u81EA\u5B9A\u4E49 resolver \u547D\u4E2D: ip=${enrichment.ip || "-"}, loc=${enrichment.location || "-"}`);
|
|
8262
8230
|
} else {
|
|
8263
|
-
|
|
8231
|
+
logger14.warning("\u81EA\u5B9A\u4E49 resolver \u5DF2\u6267\u884C\uFF0C\u4F46\u672A\u8FD4\u56DE IP/Loc");
|
|
8264
8232
|
}
|
|
8265
8233
|
return enrichment;
|
|
8266
8234
|
} finally {
|
|
@@ -8449,12 +8417,12 @@ var normalizeWatermarkifyRenderMode = (value) => {
|
|
|
8449
8417
|
};
|
|
8450
8418
|
var composeScreenshotBufferWithBrowser = async (page, buffer, overlaySvg, imageInfo = {}, options = {}) => {
|
|
8451
8419
|
if (!page || typeof page.context !== "function") {
|
|
8452
|
-
|
|
8420
|
+
logger14.warning("watermarkify \u6D4F\u89C8\u5668\u5408\u6210\u8DF3\u8FC7: \u7F3A\u5C11\u53EF\u7528 page");
|
|
8453
8421
|
return buffer;
|
|
8454
8422
|
}
|
|
8455
8423
|
const renderScope = await openProbePage(page);
|
|
8456
8424
|
if (!renderScope?.page) {
|
|
8457
|
-
|
|
8425
|
+
logger14.warning("watermarkify \u6D4F\u89C8\u5668\u5408\u6210\u8DF3\u8FC7: \u65E0\u6CD5\u521B\u5EFA render page");
|
|
8458
8426
|
return buffer;
|
|
8459
8427
|
}
|
|
8460
8428
|
try {
|
|
@@ -8519,13 +8487,13 @@ var composeScreenshotBufferWithBrowser = async (page, buffer, overlaySvg, imageI
|
|
|
8519
8487
|
fullPage: true,
|
|
8520
8488
|
animations: "disabled"
|
|
8521
8489
|
}).catch((error) => {
|
|
8522
|
-
|
|
8490
|
+
logger14.warning(`watermarkify \u6D4F\u89C8\u5668\u5408\u6210\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
8523
8491
|
return null;
|
|
8524
8492
|
});
|
|
8525
8493
|
if (Buffer.isBuffer(composed) && composed.length > 0) {
|
|
8526
8494
|
return composed;
|
|
8527
8495
|
}
|
|
8528
|
-
|
|
8496
|
+
logger14.warning("watermarkify \u6D4F\u89C8\u5668\u5408\u6210\u5931\u8D25: \u672A\u5F97\u5230\u6709\u6548\u622A\u56FE\u7ED3\u679C");
|
|
8529
8497
|
return buffer;
|
|
8530
8498
|
} finally {
|
|
8531
8499
|
await renderScope.close().catch(() => {
|
|
@@ -8538,7 +8506,7 @@ var resolveWithIpLookup = async (page, options = {}) => {
|
|
|
8538
8506
|
}
|
|
8539
8507
|
const probeScope = await openProbePage(page);
|
|
8540
8508
|
if (!probeScope?.page) {
|
|
8541
|
-
|
|
8509
|
+
logger14.warning("ipLookup \u8DF3\u8FC7: \u65E0\u6CD5\u521B\u5EFA probe page");
|
|
8542
8510
|
return null;
|
|
8543
8511
|
}
|
|
8544
8512
|
const timeoutMs = Math.max(
|
|
@@ -8547,12 +8515,12 @@ var resolveWithIpLookup = async (page, options = {}) => {
|
|
|
8547
8515
|
);
|
|
8548
8516
|
try {
|
|
8549
8517
|
const probePage = probeScope.page;
|
|
8550
|
-
|
|
8518
|
+
logger14.info(`ipLookup \u5C1D\u8BD5: url=${DEFAULT_IP_LOOKUP_URL}, timeoutMs=${timeoutMs}`);
|
|
8551
8519
|
const response = await probePage.goto(DEFAULT_IP_LOOKUP_URL, {
|
|
8552
8520
|
waitUntil: "commit",
|
|
8553
8521
|
timeout: timeoutMs
|
|
8554
8522
|
}).catch((error) => {
|
|
8555
|
-
|
|
8523
|
+
logger14.warning(`ipLookup \u8BF7\u6C42\u5931\u8D25: url=${DEFAULT_IP_LOOKUP_URL}, error=${error instanceof Error ? error.message : String(error)}`);
|
|
8556
8524
|
return null;
|
|
8557
8525
|
});
|
|
8558
8526
|
const status = response && typeof response.status === "function" ? response.status() : 0;
|
|
@@ -8574,13 +8542,13 @@ var resolveWithIpLookup = async (page, options = {}) => {
|
|
|
8574
8542
|
}
|
|
8575
8543
|
const parsed = parseIpIpJsonResponse(rawText);
|
|
8576
8544
|
if (parsed?.ip || parsed?.location) {
|
|
8577
|
-
|
|
8545
|
+
logger14.info(`ipLookup \u6210\u529F: url=${DEFAULT_IP_LOOKUP_URL}, status=${status || "-"}, contentType=${contentType || "-"}, ip=${parsed.ip || "-"}, loc=${parsed.location || "-"}`);
|
|
8578
8546
|
return parsed;
|
|
8579
8547
|
}
|
|
8580
|
-
|
|
8548
|
+
logger14.warning(`ipLookup \u672A\u89E3\u6790\u51FA IP/Loc: url=${DEFAULT_IP_LOOKUP_URL}, status=${status || "-"}, contentType=${contentType || "-"}, preview=${shortenTail(rawText, 120) || "[empty]"}`);
|
|
8581
8549
|
return null;
|
|
8582
8550
|
} catch (error) {
|
|
8583
|
-
|
|
8551
|
+
logger14.warning(`ipLookup \u6267\u884C\u5F02\u5E38\uFF0C\u672A\u83B7\u5F97 IP/Loc: ${error instanceof Error ? error.message : String(error)}`);
|
|
8584
8552
|
return null;
|
|
8585
8553
|
} finally {
|
|
8586
8554
|
await probeScope.close().catch(() => {
|
|
@@ -8594,10 +8562,10 @@ var resolveEnrichment = async (page, baseMeta, options) => {
|
|
|
8594
8562
|
ip: toInline(options.ip, 80),
|
|
8595
8563
|
location: toInline(options.location, 80)
|
|
8596
8564
|
};
|
|
8597
|
-
|
|
8565
|
+
logger14.info(`enrichment \u5F00\u59CB: host=${baseMeta.hostname || "-"}, hasPresetIp=${Boolean(merged.ip)}, hasPresetLoc=${Boolean(merged.location)}, ipLookup=${options.ipLookup !== false}`);
|
|
8598
8566
|
if (!merged.ip || !merged.location) {
|
|
8599
8567
|
if (cached?.ip || cached?.location) {
|
|
8600
|
-
|
|
8568
|
+
logger14.info(`enrichment \u547D\u4E2D\u4E0A\u4E0B\u6587\u7F13\u5B58: ip=${cached.ip || "-"}, loc=${cached.location || "-"}`);
|
|
8601
8569
|
}
|
|
8602
8570
|
fillEnrichment(merged, cached);
|
|
8603
8571
|
}
|
|
@@ -8621,15 +8589,15 @@ var resolveEnrichment = async (page, baseMeta, options) => {
|
|
|
8621
8589
|
"x-geo-country"
|
|
8622
8590
|
]), 80);
|
|
8623
8591
|
if (!merged.location || isWeakLocationValue(merged.location) && headerLocation) {
|
|
8624
|
-
|
|
8592
|
+
logger14.info(`enrichment \u4F7F\u7528\u54CD\u5E94\u5934\u8865\u5145 Loc: ${headerLocation || "-"}`);
|
|
8625
8593
|
merged.location = headerLocation || merged.location;
|
|
8626
8594
|
}
|
|
8627
8595
|
}
|
|
8628
8596
|
writeCachedEnrichment(page, merged);
|
|
8629
8597
|
if (merged.ip || merged.location) {
|
|
8630
|
-
|
|
8598
|
+
logger14.info(`enrichment \u5B8C\u6210: ip=${merged.ip || "-"}, loc=${merged.location || "-"}`);
|
|
8631
8599
|
} else {
|
|
8632
|
-
|
|
8600
|
+
logger14.warning("enrichment \u5B8C\u6210: \u672A\u83B7\u5F97 IP/Loc");
|
|
8633
8601
|
}
|
|
8634
8602
|
return merged;
|
|
8635
8603
|
};
|
|
@@ -9442,7 +9410,7 @@ var watermarkifyScreenshotBuffer = async (buffer, meta, page = null, options = {
|
|
|
9442
9410
|
}
|
|
9443
9411
|
const imageInfo = readImageInfo(buffer);
|
|
9444
9412
|
if (!imageInfo.width || !imageInfo.height || !imageInfo.mimeType) {
|
|
9445
|
-
|
|
9413
|
+
logger14.warning("watermarkify \u8DF3\u8FC7: \u65E0\u6CD5\u89E3\u6790\u622A\u56FE\u5C3A\u5BF8\u6216\u683C\u5F0F");
|
|
9446
9414
|
return buffer;
|
|
9447
9415
|
}
|
|
9448
9416
|
const isMobileStrip = normalizeDevice(meta.device) === Device.Mobile && hasStrip;
|
|
@@ -9460,7 +9428,7 @@ var watermarkifyScreenshotBuffer = async (buffer, meta, page = null, options = {
|
|
|
9460
9428
|
|
|
9461
9429
|
// src/internals/compression.js
|
|
9462
9430
|
var import_jimp = require("jimp");
|
|
9463
|
-
var
|
|
9431
|
+
var logger15 = createInternalLogger("Compression");
|
|
9464
9432
|
var DEFAULT_SCREENSHOT_MAX_BYTES = 5 * 1024 * 1024;
|
|
9465
9433
|
var DEFAULT_SCREENSHOT_OUTPUT_TYPE = "jpeg";
|
|
9466
9434
|
var DEFAULT_SCREENSHOT_QUALITY = 0.72;
|
|
@@ -9579,18 +9547,18 @@ var compressImageBufferToBase64 = async (buffer, compression) => {
|
|
|
9579
9547
|
return buffer.toString("base64");
|
|
9580
9548
|
}
|
|
9581
9549
|
const result = await compressImageBuffer(buffer, compression).catch((error) => {
|
|
9582
|
-
|
|
9550
|
+
logger15.warning(`captureScreen \u538B\u7F29\u5931\u8D25\uFF0C\u8FD4\u56DE\u539F\u56FE: ${error instanceof Error ? error.message : String(error)}`);
|
|
9583
9551
|
return null;
|
|
9584
9552
|
});
|
|
9585
9553
|
if (!result?.buffer) {
|
|
9586
9554
|
return buffer.toString("base64");
|
|
9587
9555
|
}
|
|
9588
9556
|
if (result.withinLimit) {
|
|
9589
|
-
|
|
9557
|
+
logger15.info(
|
|
9590
9558
|
`captureScreen \u5DF2\u538B\u7F29: ${originalBytes} -> ${result.bytes} bytes, format=${result.format}, quality=${result.quality}, scale=${result.scale}, size=${result.width}x${result.height}`
|
|
9591
9559
|
);
|
|
9592
9560
|
} else {
|
|
9593
|
-
|
|
9561
|
+
logger15.warning(
|
|
9594
9562
|
`captureScreen \u538B\u7F29\u540E\u4ECD\u8D85\u8FC7\u76EE\u6807: ${originalBytes} -> ${result.bytes} bytes, maxBytes=${compression.maxBytes}, format=${result.format}, quality=${result.quality}, scale=${result.scale}`
|
|
9595
9563
|
);
|
|
9596
9564
|
}
|
|
@@ -9598,7 +9566,7 @@ var compressImageBufferToBase64 = async (buffer, compression) => {
|
|
|
9598
9566
|
};
|
|
9599
9567
|
|
|
9600
9568
|
// src/share.js
|
|
9601
|
-
var
|
|
9569
|
+
var logger16 = createInternalLogger("Share");
|
|
9602
9570
|
var DEFAULT_TIMEOUT_MS2 = 50 * 1e3;
|
|
9603
9571
|
var DEFAULT_PAYLOAD_SNAPSHOT_MAX_LEN = 500;
|
|
9604
9572
|
var DEFAULT_POLL_INTERVAL_MS = 120;
|
|
@@ -9735,7 +9703,7 @@ var createDomShareMonitor = async (page, options = {}) => {
|
|
|
9735
9703
|
const onMatch = typeof options.onMatch === "function" ? options.onMatch : null;
|
|
9736
9704
|
const onTelemetry = typeof options.onTelemetry === "function" ? options.onTelemetry : null;
|
|
9737
9705
|
let matched = false;
|
|
9738
|
-
|
|
9706
|
+
logger16.info(`DOM \u76D1\u542C\u51C6\u5907\u6302\u8F7D: selectors=${toJsonInline(selectors, 120)}, mode=${mode}`);
|
|
9739
9707
|
const monitor = await Mutation.useMonitor(page, selectors, {
|
|
9740
9708
|
mode,
|
|
9741
9709
|
onMutation: (context = {}) => {
|
|
@@ -9753,12 +9721,12 @@ ${text}`;
|
|
|
9753
9721
|
});
|
|
9754
9722
|
}
|
|
9755
9723
|
if (mutationCount <= 5 || mutationCount % 50 === 0) {
|
|
9756
|
-
|
|
9724
|
+
logger16.info(`DOM \u53D8\u5316\u5DF2\u6355\u83B7: mutationCount=${mutationCount}, mutationNodes=${mutationNodes.length}`);
|
|
9757
9725
|
}
|
|
9758
9726
|
const [candidate] = Utils.parseLinks(rawDom, { prefix }) || [];
|
|
9759
9727
|
if (!candidate) return;
|
|
9760
9728
|
matched = true;
|
|
9761
|
-
|
|
9729
|
+
logger16.success("captureLink.domHit", `DOM \u547D\u4E2D\u5206\u4EAB\u94FE\u63A5: mutationCount=${mutationCount}, link=${candidate}`);
|
|
9762
9730
|
if (onMatch) {
|
|
9763
9731
|
onMatch({
|
|
9764
9732
|
link: candidate,
|
|
@@ -9774,7 +9742,7 @@ ${text}`;
|
|
|
9774
9742
|
return {
|
|
9775
9743
|
stop: async () => {
|
|
9776
9744
|
const result = await monitor.stop();
|
|
9777
|
-
|
|
9745
|
+
logger16.info(`DOM \u76D1\u542C\u5DF2\u505C\u6B62: totalMutations=${result?.totalMutations || 0}`);
|
|
9778
9746
|
return result;
|
|
9779
9747
|
}
|
|
9780
9748
|
};
|
|
@@ -9823,8 +9791,8 @@ var Share = {
|
|
|
9823
9791
|
if (share.mode === "response" && apiMatchers.length === 0) {
|
|
9824
9792
|
throw new Error("Share.captureLink requires share.xurl[0] api matcher when mode=response");
|
|
9825
9793
|
}
|
|
9826
|
-
|
|
9827
|
-
|
|
9794
|
+
logger16.start("captureLink", `mode=${share.mode}, timeoutMs=${timeoutDisabled ? "disabled" : timeoutMs}, prefix=${share.prefix}`);
|
|
9795
|
+
logger16.info(`captureLink \u914D\u7F6E: xurl=${toJsonInline(share.xurl)}, domMode=${domMode}, domSelectors=${toJsonInline(domSelectors, 120)}`);
|
|
9828
9796
|
const stats = {
|
|
9829
9797
|
actionTimedOut: false,
|
|
9830
9798
|
domMutationCount: 0,
|
|
@@ -9836,7 +9804,7 @@ var Share = {
|
|
|
9836
9804
|
responseSampleUrls: []
|
|
9837
9805
|
};
|
|
9838
9806
|
if (isAborted()) {
|
|
9839
|
-
|
|
9807
|
+
logger16.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
|
|
9840
9808
|
return {
|
|
9841
9809
|
link: null,
|
|
9842
9810
|
payloadText: "",
|
|
@@ -9859,7 +9827,7 @@ var Share = {
|
|
|
9859
9827
|
link: validated,
|
|
9860
9828
|
payloadText: String(payloadText || "")
|
|
9861
9829
|
};
|
|
9862
|
-
|
|
9830
|
+
logger16.info(`\u5019\u9009\u94FE\u63A5\u5DF2\u786E\u8BA4: source=${source}, link=${validated}`);
|
|
9863
9831
|
return true;
|
|
9864
9832
|
};
|
|
9865
9833
|
const resolveResponseCandidate = (responseText) => {
|
|
@@ -9894,7 +9862,7 @@ var Share = {
|
|
|
9894
9862
|
try {
|
|
9895
9863
|
await monitor.stop();
|
|
9896
9864
|
} catch (error) {
|
|
9897
|
-
|
|
9865
|
+
logger16.warning(`\u505C\u6B62 DOM \u76D1\u542C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
9898
9866
|
}
|
|
9899
9867
|
};
|
|
9900
9868
|
const onResponse = async (response) => {
|
|
@@ -9908,29 +9876,29 @@ var Share = {
|
|
|
9908
9876
|
stats.responseSampleUrls.push(url);
|
|
9909
9877
|
}
|
|
9910
9878
|
if (stats.responseObserved <= 5) {
|
|
9911
|
-
|
|
9879
|
+
logger16.info(`\u63A5\u53E3\u54CD\u5E94\u91C7\u6837(${stats.responseObserved}): ${url}`);
|
|
9912
9880
|
}
|
|
9913
9881
|
if (!apiMatchers.some((matcher) => url.includes(matcher))) return;
|
|
9914
9882
|
stats.responseMatched += 1;
|
|
9915
9883
|
stats.lastMatchedUrl = url;
|
|
9916
|
-
|
|
9884
|
+
logger16.info(`\u63A5\u53E3\u547D\u4E2D\u5339\u914D(${stats.responseMatched}): ${url}`);
|
|
9917
9885
|
const text = await response.text();
|
|
9918
9886
|
const hit = resolveResponseCandidate(text);
|
|
9919
9887
|
if (!hit?.link) {
|
|
9920
9888
|
if (stats.responseMatched <= 3) {
|
|
9921
|
-
|
|
9889
|
+
logger16.info(`\u63A5\u53E3\u89E3\u6790\u5B8C\u6210\u4F46\u672A\u63D0\u53D6\u5230\u5206\u4EAB\u94FE\u63A5: payloadSize=${text.length}`);
|
|
9922
9890
|
}
|
|
9923
9891
|
return;
|
|
9924
9892
|
}
|
|
9925
9893
|
stats.responseResolved += 1;
|
|
9926
|
-
|
|
9894
|
+
logger16.success("captureLink.responseHit", `\u63A5\u53E3\u547D\u4E2D\u5206\u4EAB\u94FE\u63A5: url=${url}, link=${hit.link}`);
|
|
9927
9895
|
setCandidate("response", hit.link, hit.payloadText);
|
|
9928
9896
|
} catch (error) {
|
|
9929
|
-
|
|
9897
|
+
logger16.warning(`\u63A5\u53E3\u54CD\u5E94\u5904\u7406\u5F02\u5E38: ${error instanceof Error ? error.message : String(error)}`);
|
|
9930
9898
|
}
|
|
9931
9899
|
};
|
|
9932
9900
|
if (share.mode === "dom") {
|
|
9933
|
-
|
|
9901
|
+
logger16.info("\u5F53\u524D\u4E3A DOM \u6A21\u5F0F\uFF0C\u4EC5\u542F\u7528 DOM \u76D1\u542C");
|
|
9934
9902
|
domMonitor = await createDomShareMonitor(page, {
|
|
9935
9903
|
prefix: share.prefix,
|
|
9936
9904
|
selectors: domSelectors,
|
|
@@ -9945,17 +9913,17 @@ var Share = {
|
|
|
9945
9913
|
});
|
|
9946
9914
|
}
|
|
9947
9915
|
if (share.mode === "response") {
|
|
9948
|
-
|
|
9916
|
+
logger16.info(`\u5F53\u524D\u4E3A\u63A5\u53E3\u6A21\u5F0F\uFF0C\u6302\u8F7D response \u76D1\u542C: apiMatchers=${toJsonInline(apiMatchers, 160)}`);
|
|
9949
9917
|
page.on("response", onResponse);
|
|
9950
9918
|
}
|
|
9951
9919
|
if (share.mode === "custom") {
|
|
9952
|
-
|
|
9920
|
+
logger16.info("\u5F53\u524D\u4E3A custom \u6A21\u5F0F\uFF0C\u5C06\u4F7F\u7528 performActions \u8FD4\u56DE\u503C");
|
|
9953
9921
|
}
|
|
9954
9922
|
const deadline = timeoutDisabled ? Infinity : Date.now() + timeoutMs;
|
|
9955
9923
|
const getRemainingMs = () => timeoutDisabled ? Infinity : Math.max(0, deadline - Date.now());
|
|
9956
9924
|
try {
|
|
9957
9925
|
const actionTimeout = getRemainingMs();
|
|
9958
|
-
|
|
9926
|
+
logger16.start("captureLink.performActions", `\u6267\u884C\u52A8\u4F5C\u9884\u7B97=${timeoutDisabled ? "disabled" : `${actionTimeout}ms`}`);
|
|
9959
9927
|
let actionValue;
|
|
9960
9928
|
if (!isAborted() && actionTimeout > 0) {
|
|
9961
9929
|
let timer = null;
|
|
@@ -9968,30 +9936,30 @@ var Share = {
|
|
|
9968
9936
|
]);
|
|
9969
9937
|
if (timer) clearTimeout(timer);
|
|
9970
9938
|
if (actionResult.type === "error") {
|
|
9971
|
-
|
|
9939
|
+
logger16.fail("captureLink.performActions", actionResult.error);
|
|
9972
9940
|
throw actionResult.error;
|
|
9973
9941
|
}
|
|
9974
9942
|
if (actionResult.type === "timeout") {
|
|
9975
9943
|
stats.actionTimedOut = true;
|
|
9976
|
-
|
|
9944
|
+
logger16.warning(`performActions \u5DF2\u8D85\u65F6 (${actionTimeout}ms)\uFF0C\u52A8\u4F5C\u53EF\u80FD\u4ECD\u5728\u5F02\u6B65\u6267\u884C`);
|
|
9977
9945
|
} else {
|
|
9978
9946
|
actionValue = actionResult.result;
|
|
9979
|
-
|
|
9947
|
+
logger16.success("captureLink.performActions", "\u6267\u884C\u52A8\u4F5C\u5B8C\u6210");
|
|
9980
9948
|
}
|
|
9981
9949
|
}
|
|
9982
9950
|
if (share.mode === "custom") {
|
|
9983
9951
|
const customLink = typeof actionValue === "string" ? actionValue : actionValue?.link || actionValue?.payloadText;
|
|
9984
9952
|
const customPayloadText = typeof actionValue === "string" ? actionValue : actionValue?.payloadText;
|
|
9985
9953
|
if (setCandidate("custom", customLink, customPayloadText)) {
|
|
9986
|
-
|
|
9954
|
+
logger16.success("captureLink.customResult", `custom \u547D\u4E2D\u5206\u4EAB\u94FE\u63A5: link=${candidates.custom.link}`);
|
|
9987
9955
|
} else {
|
|
9988
|
-
|
|
9956
|
+
logger16.warning("performActions \u6267\u884C\u5B8C\u6210\u4F46\u672A\u8FD4\u56DE\u6709\u6548\u5206\u4EAB\u94FE\u63A5");
|
|
9989
9957
|
}
|
|
9990
9958
|
}
|
|
9991
9959
|
let nextProgressLogTs = Date.now() + 3e3;
|
|
9992
9960
|
while (true) {
|
|
9993
9961
|
if (isAborted()) {
|
|
9994
|
-
|
|
9962
|
+
logger16.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
|
|
9995
9963
|
return {
|
|
9996
9964
|
link: null,
|
|
9997
9965
|
payloadText: "",
|
|
@@ -10001,7 +9969,7 @@ var Share = {
|
|
|
10001
9969
|
}
|
|
10002
9970
|
const selected = candidates[share.mode];
|
|
10003
9971
|
if (selected?.link) {
|
|
10004
|
-
|
|
9972
|
+
logger16.success("captureLink", `\u6355\u83B7\u6210\u529F: source=${share.mode}, link=${selected.link}`);
|
|
10005
9973
|
return {
|
|
10006
9974
|
link: selected.link,
|
|
10007
9975
|
payloadText: selected.payloadText,
|
|
@@ -10014,7 +9982,7 @@ var Share = {
|
|
|
10014
9982
|
if (remaining <= 0) break;
|
|
10015
9983
|
const now = Date.now();
|
|
10016
9984
|
if (now >= nextProgressLogTs) {
|
|
10017
|
-
|
|
9985
|
+
logger16.info(
|
|
10018
9986
|
`captureLink \u7B49\u5F85\u4E2D: remaining=${timeoutDisabled ? "disabled" : `${remaining}ms`}, domMutationCount=${stats.domMutationCount}, responseMatched=${stats.responseMatched}`
|
|
10019
9987
|
);
|
|
10020
9988
|
nextProgressLogTs = now + 5e3;
|
|
@@ -10022,11 +9990,11 @@ var Share = {
|
|
|
10022
9990
|
await (0, import_delay5.default)(Math.max(0, Math.min(DEFAULT_POLL_INTERVAL_MS, remaining)));
|
|
10023
9991
|
}
|
|
10024
9992
|
if (!timeoutDisabled && share.mode === "response" && stats.responseMatched === 0) {
|
|
10025
|
-
|
|
9993
|
+
logger16.warning(
|
|
10026
9994
|
`\u63A5\u53E3\u76D1\u542C\u672A\u547D\u4E2D: apiMatchers=${toJsonInline(apiMatchers, 220)}, \u54CD\u5E94\u6837\u672CURLs=${toJsonInline(stats.responseSampleUrls, 420)}`
|
|
10027
9995
|
);
|
|
10028
9996
|
}
|
|
10029
|
-
|
|
9997
|
+
logger16.warning(
|
|
10030
9998
|
`captureLink ${timeoutDisabled ? "\u672A\u62FF\u5230\u94FE\u63A5" : "\u8D85\u65F6\u672A\u62FF\u5230\u94FE\u63A5"}: mode=${share.mode}, actionTimedOut=${stats.actionTimedOut}, domMutationCount=${stats.domMutationCount}, responseObserved=${stats.responseObserved}, responseMatched=${stats.responseMatched}, lastMatchedUrl=${stats.lastMatchedUrl || "none"}`
|
|
10031
9999
|
);
|
|
10032
10000
|
return {
|
|
@@ -10038,7 +10006,7 @@ var Share = {
|
|
|
10038
10006
|
} finally {
|
|
10039
10007
|
if (share.mode === "response") {
|
|
10040
10008
|
page.off("response", onResponse);
|
|
10041
|
-
|
|
10009
|
+
logger16.info("response \u76D1\u542C\u5DF2\u5378\u8F7D");
|
|
10042
10010
|
}
|
|
10043
10011
|
await stopDomMonitor();
|
|
10044
10012
|
}
|