@skrillex1224/playwright-toolkit 3.0.2 → 3.0.3
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.js
CHANGED
|
@@ -360,18 +360,18 @@ var fallbackLog = {
|
|
|
360
360
|
error: (...args) => console.error(...args),
|
|
361
361
|
debug: (...args) => console.debug ? console.debug(...args) : console.log(...args)
|
|
362
362
|
};
|
|
363
|
-
var resolveLogMethod = (
|
|
364
|
-
if (
|
|
365
|
-
return
|
|
363
|
+
var resolveLogMethod = (logger17, name) => {
|
|
364
|
+
if (logger17 && typeof logger17[name] === "function") {
|
|
365
|
+
return logger17[name].bind(logger17);
|
|
366
366
|
}
|
|
367
|
-
if (name === "warning" &&
|
|
368
|
-
return
|
|
367
|
+
if (name === "warning" && logger17 && typeof logger17.warn === "function") {
|
|
368
|
+
return logger17.warn.bind(logger17);
|
|
369
369
|
}
|
|
370
370
|
return fallbackLog[name];
|
|
371
371
|
};
|
|
372
372
|
var defaultLogger = null;
|
|
373
|
-
var setDefaultLogger = (
|
|
374
|
-
defaultLogger =
|
|
373
|
+
var setDefaultLogger = (logger17) => {
|
|
374
|
+
defaultLogger = logger17;
|
|
375
375
|
};
|
|
376
376
|
var resolveLogger = (explicitLogger) => {
|
|
377
377
|
if (explicitLogger && typeof explicitLogger.info === "function") {
|
|
@@ -398,8 +398,8 @@ var colorize = (text, color) => {
|
|
|
398
398
|
var createBaseLogger = (prefix = "", explicitLogger) => {
|
|
399
399
|
const name = prefix ? String(prefix) : "";
|
|
400
400
|
const dispatch = (methodName, icon, message, color) => {
|
|
401
|
-
const
|
|
402
|
-
const logFn = resolveLogMethod(
|
|
401
|
+
const logger17 = resolveLogger(explicitLogger);
|
|
402
|
+
const logFn = resolveLogMethod(logger17, methodName);
|
|
403
403
|
const timestamp = colorize(`[${formatTimestamp()}]`, ANSI.gray);
|
|
404
404
|
const line = formatLine(name, icon, message);
|
|
405
405
|
const coloredLine = colorize(line, color);
|
|
@@ -4837,9 +4837,107 @@ var ByPass = {
|
|
|
4837
4837
|
resolveRouteByProxy
|
|
4838
4838
|
};
|
|
4839
4839
|
|
|
4840
|
-
// src/internals/launch/
|
|
4840
|
+
// src/internals/launch/traffic.js
|
|
4841
4841
|
var logger7 = createInternalLogger("Launch");
|
|
4842
|
-
var
|
|
4842
|
+
var normalizeObject = (value) => {
|
|
4843
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
4844
|
+
return {};
|
|
4845
|
+
}
|
|
4846
|
+
return value;
|
|
4847
|
+
};
|
|
4848
|
+
var parseProxyConfiguration = (proxyConfiguration = {}) => {
|
|
4849
|
+
const config = normalizeObject(proxyConfiguration);
|
|
4850
|
+
const proxyUrl = String(config.proxy_url || "").trim();
|
|
4851
|
+
const enableProxy = typeof config.enable_proxy === "boolean" ? config.enable_proxy : proxyUrl !== "";
|
|
4852
|
+
const byPassDomains = enableProxy && proxyUrl ? ByPass.normalizeByPassDomains(config.by_pass_domains) : [];
|
|
4853
|
+
return {
|
|
4854
|
+
byPassDomains,
|
|
4855
|
+
enableProxy,
|
|
4856
|
+
proxyUrl
|
|
4857
|
+
};
|
|
4858
|
+
};
|
|
4859
|
+
var resolveLaunchTraffic = ({
|
|
4860
|
+
proxyConfiguration = {},
|
|
4861
|
+
debugMode = false,
|
|
4862
|
+
useMeter = true
|
|
4863
|
+
} = {}) => {
|
|
4864
|
+
const { byPassDomains, enableProxy, proxyUrl } = parseProxyConfiguration(proxyConfiguration);
|
|
4865
|
+
const byPassRules = ByPass.buildByPassDomainRules(byPassDomains);
|
|
4866
|
+
const proxyMeter = useMeter && enableProxy && proxyUrl ? ProxyMeterRuntime.startProxyMeter({ proxyUrl, debugMode }) : null;
|
|
4867
|
+
const launchProxy = proxyMeter ? { server: proxyMeter.server } : null;
|
|
4868
|
+
if (launchProxy && byPassDomains.length > 0) {
|
|
4869
|
+
launchProxy.bypass = byPassDomains.join(",");
|
|
4870
|
+
}
|
|
4871
|
+
return {
|
|
4872
|
+
byPassDomains,
|
|
4873
|
+
byPassRules,
|
|
4874
|
+
enableProxy,
|
|
4875
|
+
proxyUrl,
|
|
4876
|
+
launchProxy
|
|
4877
|
+
};
|
|
4878
|
+
};
|
|
4879
|
+
var logLaunchTraffic = ({
|
|
4880
|
+
byPassDomains = [],
|
|
4881
|
+
debugMode = false,
|
|
4882
|
+
enabled = false,
|
|
4883
|
+
enableProxy = false,
|
|
4884
|
+
explicitProxy = false,
|
|
4885
|
+
launchProxy = null,
|
|
4886
|
+
proxyUrl = ""
|
|
4887
|
+
} = {}) => {
|
|
4888
|
+
if (!enabled) return;
|
|
4889
|
+
if (explicitProxy) {
|
|
4890
|
+
logger7.info("[\u4EE3\u7406\u5DF2\u542F\u7528] \u4F7F\u7528\u663E\u5F0F proxy \u914D\u7F6E\uFF0C\u8DF3\u8FC7 toolkit \u672C\u5730\u6D41\u91CF\u89C2\u6D4B");
|
|
4891
|
+
return;
|
|
4892
|
+
}
|
|
4893
|
+
if (launchProxy) {
|
|
4894
|
+
let upstreamLabel = "";
|
|
4895
|
+
try {
|
|
4896
|
+
const parsedProxyUrl = new URL(proxyUrl.includes("://") ? proxyUrl : `http://${proxyUrl}`);
|
|
4897
|
+
upstreamLabel = `${parsedProxyUrl.protocol}//${parsedProxyUrl.host}`;
|
|
4898
|
+
} catch {
|
|
4899
|
+
}
|
|
4900
|
+
logger7.info(
|
|
4901
|
+
`[\u4EE3\u7406\u5DF2\u542F\u7528] \u672C\u5730=${launchProxy.server} \u4E0A\u6E38=${upstreamLabel || "-"} \u76F4\u8FDE\u57DF\u540D=${byPassDomains.join(",")}`
|
|
4902
|
+
);
|
|
4903
|
+
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`);
|
|
4904
|
+
return;
|
|
4905
|
+
}
|
|
4906
|
+
if (enableProxy) {
|
|
4907
|
+
logger7.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=true \u4F46 proxy_url \u4E3A\u7A7A");
|
|
4908
|
+
} else if (proxyUrl) {
|
|
4909
|
+
logger7.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=false \u4E14 proxy_url \u5DF2\u914D\u7F6E");
|
|
4910
|
+
}
|
|
4911
|
+
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`);
|
|
4912
|
+
};
|
|
4913
|
+
var createLaunchTrafficHook = ({
|
|
4914
|
+
byPassDomains = [],
|
|
4915
|
+
byPassRules = [],
|
|
4916
|
+
enabled = false,
|
|
4917
|
+
launchProxy = null
|
|
4918
|
+
} = {}) => {
|
|
4919
|
+
const patchedPages = /* @__PURE__ */ new WeakSet();
|
|
4920
|
+
return (page) => {
|
|
4921
|
+
if (!page || typeof page.on !== "function" || patchedPages.has(page)) {
|
|
4922
|
+
return;
|
|
4923
|
+
}
|
|
4924
|
+
patchedPages.add(page);
|
|
4925
|
+
page.on("request", (req) => {
|
|
4926
|
+
const requestUrl = req.url();
|
|
4927
|
+
const resourceType = req.resourceType();
|
|
4928
|
+
const matched = byPassDomains.length > 0 ? ByPass.findMatchedByPassRule(byPassRules, requestUrl) : null;
|
|
4929
|
+
if (launchProxy) {
|
|
4930
|
+
ProxyMeterRuntime.recordProxyMeterResourceType(requestUrl, resourceType);
|
|
4931
|
+
}
|
|
4932
|
+
if (!enabled || byPassDomains.length === 0) return;
|
|
4933
|
+
if (!matched || !matched.rule) return;
|
|
4934
|
+
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}`);
|
|
4935
|
+
});
|
|
4936
|
+
};
|
|
4937
|
+
};
|
|
4938
|
+
|
|
4939
|
+
// src/internals/launch/default.js
|
|
4940
|
+
var logger8 = createInternalLogger("Launch");
|
|
4843
4941
|
var injectedContexts = /* @__PURE__ */ new WeakSet();
|
|
4844
4942
|
var browserMajorVersionCache = /* @__PURE__ */ new Map();
|
|
4845
4943
|
var DEFAULT_BROWSER_PROFILE_SCHEMA_VERSION = 1;
|
|
@@ -4851,16 +4949,6 @@ var DEFAULT_CRAWLER_BASE_OPTIONS = Object.freeze({
|
|
|
4851
4949
|
navigationTimeoutSecs: 120
|
|
4852
4950
|
});
|
|
4853
4951
|
var fingerprintInjector = new FingerprintInjector();
|
|
4854
|
-
var resolveProxyLaunchOptions = (proxyConfiguration = {}) => {
|
|
4855
|
-
const config = proxyConfiguration && typeof proxyConfiguration === "object" && !Array.isArray(proxyConfiguration) ? proxyConfiguration : {};
|
|
4856
|
-
const proxyUrl = String(config.proxy_url || "").trim();
|
|
4857
|
-
const enableProxy = typeof config.enable_proxy === "boolean" ? config.enable_proxy : proxyUrl !== "";
|
|
4858
|
-
if (!enableProxy || !proxyUrl) {
|
|
4859
|
-
return { byPassDomains: [], enableProxy, proxyUrl };
|
|
4860
|
-
}
|
|
4861
|
-
const byPassDomains = ByPass.normalizeByPassDomains(config.by_pass_domains);
|
|
4862
|
-
return { byPassDomains, enableProxy, proxyUrl };
|
|
4863
|
-
};
|
|
4864
4952
|
var parseChromeMajorVersion = (rawValue = "") => {
|
|
4865
4953
|
const match = String(rawValue || "").match(/(?:Chrome|Chromium)(?:\/|\s+(?:for Testing\s+)?)(\d+)/i);
|
|
4866
4954
|
return match ? Number(match[1] || 0) : 0;
|
|
@@ -4890,7 +4978,7 @@ var detectBrowserMajorVersion = (launcher) => {
|
|
|
4890
4978
|
});
|
|
4891
4979
|
detectedVersion = parseChromeMajorVersion(rawVersion);
|
|
4892
4980
|
} catch (error) {
|
|
4893
|
-
|
|
4981
|
+
logger8.warn(`\u8BFB\u53D6\u6D4F\u89C8\u5668\u7248\u672C\u5931\u8D25: ${error?.message || error}`);
|
|
4894
4982
|
}
|
|
4895
4983
|
browserMajorVersionCache.set(executablePath, detectedVersion);
|
|
4896
4984
|
return detectedVersion;
|
|
@@ -4927,7 +5015,7 @@ var generateFingerprintForCore = ({ locale, browserMajorVersion, device }) => {
|
|
|
4927
5015
|
if (requestedBrowserMajorVersion <= 0) {
|
|
4928
5016
|
throw error;
|
|
4929
5017
|
}
|
|
4930
|
-
|
|
5018
|
+
logger8.warn(
|
|
4931
5019
|
`\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}`
|
|
4932
5020
|
);
|
|
4933
5021
|
}
|
|
@@ -4972,7 +5060,7 @@ var buildReplayableBrowserProfile = (runtimeState, launcher) => {
|
|
|
4972
5060
|
schema_version: DEFAULT_BROWSER_PROFILE_SCHEMA_VERSION
|
|
4973
5061
|
};
|
|
4974
5062
|
nextState = RuntimeEnv.setBrowserProfileCore(nextState, browserProfileCore);
|
|
4975
|
-
|
|
5063
|
+
logger8.info(
|
|
4976
5064
|
`\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}`
|
|
4977
5065
|
);
|
|
4978
5066
|
return { runtimeState: nextState, browserProfileCore };
|
|
@@ -5073,13 +5161,12 @@ var DefaultLaunch = {
|
|
|
5073
5161
|
runtimeState = null
|
|
5074
5162
|
} = normalizedOptions;
|
|
5075
5163
|
const device = resolveRuntimeDevice(runtimeState);
|
|
5076
|
-
const
|
|
5077
|
-
const
|
|
5078
|
-
const
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
}
|
|
5164
|
+
const enableByPassLogger = Boolean(logOptions && logOptions.enable);
|
|
5165
|
+
const traffic = resolveLaunchTraffic({ proxyConfiguration, debugMode });
|
|
5166
|
+
const trafficHook = createLaunchTrafficHook({
|
|
5167
|
+
...traffic,
|
|
5168
|
+
enabled: enableByPassLogger
|
|
5169
|
+
});
|
|
5083
5170
|
const replayContext = buildReplayableBrowserProfile(runtimeState, launcher);
|
|
5084
5171
|
const replayBrowserPoolOptions = buildReplayBrowserPoolOptions(replayContext.browserProfileCore);
|
|
5085
5172
|
const launchLocale = String(replayContext.browserProfileCore?.locale || DEFAULT_LOCALE).trim() || DEFAULT_LOCALE;
|
|
@@ -5090,30 +5177,14 @@ var DefaultLaunch = {
|
|
|
5090
5177
|
],
|
|
5091
5178
|
ignoreDefaultArgs: ["--enable-automation"]
|
|
5092
5179
|
};
|
|
5093
|
-
if (launchProxy) {
|
|
5094
|
-
launchOptions.proxy = launchProxy;
|
|
5095
|
-
}
|
|
5096
|
-
const enableByPassLogger = Boolean(logOptions && logOptions.enable);
|
|
5097
|
-
if (enableByPassLogger && launchProxy) {
|
|
5098
|
-
let upstreamLabel = "";
|
|
5099
|
-
try {
|
|
5100
|
-
const parsedProxyUrl = new URL(proxyUrl.includes("://") ? proxyUrl : `http://${proxyUrl}`);
|
|
5101
|
-
upstreamLabel = `${parsedProxyUrl.protocol}//${parsedProxyUrl.host}`;
|
|
5102
|
-
} catch {
|
|
5103
|
-
}
|
|
5104
|
-
logger7.info(
|
|
5105
|
-
`[\u4EE3\u7406\u5DF2\u542F\u7528] \u672C\u5730=${launchProxy.server} \u4E0A\u6E38=${upstreamLabel || "-"} \u76F4\u8FDE\u57DF\u540D=${(byPassDomains || []).join(",")}`
|
|
5106
|
-
);
|
|
5107
|
-
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`);
|
|
5108
|
-
} else if (enableByPassLogger && enableProxy && !launchProxy) {
|
|
5109
|
-
logger7.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=true \u4F46 proxy_url \u4E3A\u7A7A");
|
|
5110
|
-
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`);
|
|
5111
|
-
} else if (enableByPassLogger && !enableProxy && proxyUrl) {
|
|
5112
|
-
logger7.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=false \u4E14 proxy_url \u5DF2\u914D\u7F6E");
|
|
5113
|
-
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`);
|
|
5114
|
-
} else if (enableByPassLogger) {
|
|
5115
|
-
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`);
|
|
5180
|
+
if (traffic.launchProxy) {
|
|
5181
|
+
launchOptions.proxy = traffic.launchProxy;
|
|
5116
5182
|
}
|
|
5183
|
+
logLaunchTraffic({
|
|
5184
|
+
...traffic,
|
|
5185
|
+
debugMode,
|
|
5186
|
+
enabled: enableByPassLogger
|
|
5187
|
+
});
|
|
5117
5188
|
const onPageCreated = (page) => {
|
|
5118
5189
|
const recommendedGotoOptions = {
|
|
5119
5190
|
waitUntil: "commit"
|
|
@@ -5121,22 +5192,7 @@ var DefaultLaunch = {
|
|
|
5121
5192
|
if (!page || typeof page.on !== "function") {
|
|
5122
5193
|
return recommendedGotoOptions;
|
|
5123
5194
|
}
|
|
5124
|
-
|
|
5125
|
-
return recommendedGotoOptions;
|
|
5126
|
-
}
|
|
5127
|
-
page[REQUEST_HOOK_FLAG] = true;
|
|
5128
|
-
const requestHandler = (req) => {
|
|
5129
|
-
const requestUrl = req.url();
|
|
5130
|
-
const resourceType = req.resourceType();
|
|
5131
|
-
const matched = byPassDomains.length > 0 ? ByPass.findMatchedByPassRule(byPassRules, requestUrl) : null;
|
|
5132
|
-
if (launchProxy) {
|
|
5133
|
-
ProxyMeterRuntime.recordProxyMeterResourceType(requestUrl, resourceType);
|
|
5134
|
-
}
|
|
5135
|
-
if (!enableByPassLogger || byPassDomains.length === 0) return;
|
|
5136
|
-
if (!matched || !matched.rule) return;
|
|
5137
|
-
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}`);
|
|
5138
|
-
};
|
|
5139
|
-
page.on("request", requestHandler);
|
|
5195
|
+
trafficHook(page);
|
|
5140
5196
|
return recommendedGotoOptions;
|
|
5141
5197
|
};
|
|
5142
5198
|
const launchContext = {
|
|
@@ -5191,9 +5247,8 @@ var DefaultLaunch = {
|
|
|
5191
5247
|
// src/internals/launch/cloak.js
|
|
5192
5248
|
import { execFile } from "node:child_process";
|
|
5193
5249
|
import { promisify } from "node:util";
|
|
5194
|
-
var
|
|
5250
|
+
var logger9 = createInternalLogger("Launch");
|
|
5195
5251
|
var execFileAsync = promisify(execFile);
|
|
5196
|
-
var REQUEST_HOOK_FLAG2 = Symbol("playwright-toolkit-cloak-request-hook");
|
|
5197
5252
|
var DEFAULT_CLOAK_CRAWLER_BASE_OPTIONS = Object.freeze({
|
|
5198
5253
|
maxConcurrency: 1,
|
|
5199
5254
|
maxRequestRetries: 0,
|
|
@@ -5221,9 +5276,9 @@ var loadCloakModule = async () => {
|
|
|
5221
5276
|
};
|
|
5222
5277
|
var buildCloakLaunchOptions = async (options = {}) => {
|
|
5223
5278
|
const { buildLaunchOptions } = await loadCloakModule();
|
|
5224
|
-
return await buildLaunchOptions(
|
|
5279
|
+
return await buildLaunchOptions(normalizeObject2(options));
|
|
5225
5280
|
};
|
|
5226
|
-
var
|
|
5281
|
+
var normalizeObject2 = (value) => {
|
|
5227
5282
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
5228
5283
|
return {};
|
|
5229
5284
|
}
|
|
@@ -5236,7 +5291,7 @@ var normalizeStringArray = (value) => {
|
|
|
5236
5291
|
return value.map((item) => String(item || "").trim()).filter(Boolean);
|
|
5237
5292
|
};
|
|
5238
5293
|
var resolveCloakProxy = (proxyConfiguration = {}) => {
|
|
5239
|
-
const config =
|
|
5294
|
+
const config = normalizeObject2(proxyConfiguration);
|
|
5240
5295
|
const proxyUrl = String(config.proxy_url || "").trim();
|
|
5241
5296
|
const enableProxy = typeof config.enable_proxy === "boolean" ? config.enable_proxy : proxyUrl !== "";
|
|
5242
5297
|
if (!enableProxy || !proxyUrl) {
|
|
@@ -5254,92 +5309,12 @@ var resolveCloakProxy = (proxyConfiguration = {}) => {
|
|
|
5254
5309
|
bypass: byPassDomains.join(",")
|
|
5255
5310
|
};
|
|
5256
5311
|
};
|
|
5257
|
-
var resolveProxyLaunchOptions2 = (proxyConfiguration = {}) => {
|
|
5258
|
-
const config = normalizeObject(proxyConfiguration);
|
|
5259
|
-
const proxyUrl = String(config.proxy_url || "").trim();
|
|
5260
|
-
const enableProxy = typeof config.enable_proxy === "boolean" ? config.enable_proxy : proxyUrl !== "";
|
|
5261
|
-
const byPassDomains = enableProxy && proxyUrl ? ByPass.normalizeByPassDomains(config.by_pass_domains) : [];
|
|
5262
|
-
return {
|
|
5263
|
-
byPassDomains,
|
|
5264
|
-
enableProxy,
|
|
5265
|
-
proxyUrl
|
|
5266
|
-
};
|
|
5267
|
-
};
|
|
5268
|
-
var buildMeteredProxy = ({ proxyConfiguration = {}, debugMode = false } = {}) => {
|
|
5269
|
-
const { byPassDomains, enableProxy, proxyUrl } = resolveProxyLaunchOptions2(proxyConfiguration);
|
|
5270
|
-
const byPassRules = ByPass.buildByPassDomainRules(byPassDomains);
|
|
5271
|
-
const proxyMeter = enableProxy && proxyUrl ? ProxyMeterRuntime.startProxyMeter({ proxyUrl, debugMode }) : null;
|
|
5272
|
-
const launchProxy = proxyMeter ? { server: proxyMeter.server } : null;
|
|
5273
|
-
if (launchProxy && byPassDomains.length > 0) {
|
|
5274
|
-
launchProxy.bypass = byPassDomains.join(",");
|
|
5275
|
-
}
|
|
5276
|
-
return {
|
|
5277
|
-
byPassDomains,
|
|
5278
|
-
byPassRules,
|
|
5279
|
-
enableProxy,
|
|
5280
|
-
proxyUrl,
|
|
5281
|
-
launchProxy
|
|
5282
|
-
};
|
|
5283
|
-
};
|
|
5284
|
-
var logProxyLaunchState = ({
|
|
5285
|
-
byPassDomains = [],
|
|
5286
|
-
debugMode = false,
|
|
5287
|
-
enableByPassLogger = false,
|
|
5288
|
-
enableProxy = false,
|
|
5289
|
-
launchProxy = null,
|
|
5290
|
-
proxyUrl = ""
|
|
5291
|
-
} = {}) => {
|
|
5292
|
-
if (!enableByPassLogger) return;
|
|
5293
|
-
if (launchProxy) {
|
|
5294
|
-
let upstreamLabel = "";
|
|
5295
|
-
try {
|
|
5296
|
-
const parsedProxyUrl = new URL(proxyUrl.includes("://") ? proxyUrl : `http://${proxyUrl}`);
|
|
5297
|
-
upstreamLabel = `${parsedProxyUrl.protocol}//${parsedProxyUrl.host}`;
|
|
5298
|
-
} catch {
|
|
5299
|
-
}
|
|
5300
|
-
logger8.info(
|
|
5301
|
-
`[\u4EE3\u7406\u5DF2\u542F\u7528] \u672C\u5730=${launchProxy.server} \u4E0A\u6E38=${upstreamLabel || "-"} \u76F4\u8FDE\u57DF\u540D=${byPassDomains.join(",")}`
|
|
5302
|
-
);
|
|
5303
|
-
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`);
|
|
5304
|
-
return;
|
|
5305
|
-
}
|
|
5306
|
-
if (enableProxy) {
|
|
5307
|
-
logger8.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=true \u4F46 proxy_url \u4E3A\u7A7A");
|
|
5308
|
-
} else if (proxyUrl) {
|
|
5309
|
-
logger8.info("[\u4EE3\u7406\u672A\u542F\u7528] enable_proxy=false \u4E14 proxy_url \u5DF2\u914D\u7F6E");
|
|
5310
|
-
}
|
|
5311
|
-
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`);
|
|
5312
|
-
};
|
|
5313
|
-
var createProxyRequestHook = ({
|
|
5314
|
-
byPassDomains = [],
|
|
5315
|
-
byPassRules = [],
|
|
5316
|
-
enableByPassLogger = false,
|
|
5317
|
-
launchProxy = null
|
|
5318
|
-
} = {}) => {
|
|
5319
|
-
return (page) => {
|
|
5320
|
-
if (!page || typeof page.on !== "function" || page[REQUEST_HOOK_FLAG2]) {
|
|
5321
|
-
return;
|
|
5322
|
-
}
|
|
5323
|
-
page[REQUEST_HOOK_FLAG2] = true;
|
|
5324
|
-
page.on("request", (req) => {
|
|
5325
|
-
const requestUrl = req.url();
|
|
5326
|
-
const resourceType = req.resourceType();
|
|
5327
|
-
const matched = byPassDomains.length > 0 ? ByPass.findMatchedByPassRule(byPassRules, requestUrl) : null;
|
|
5328
|
-
if (launchProxy) {
|
|
5329
|
-
ProxyMeterRuntime.recordProxyMeterResourceType(requestUrl, resourceType);
|
|
5330
|
-
}
|
|
5331
|
-
if (!enableByPassLogger || byPassDomains.length === 0) return;
|
|
5332
|
-
if (!matched || !matched.rule) return;
|
|
5333
|
-
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}`);
|
|
5334
|
-
});
|
|
5335
|
-
};
|
|
5336
|
-
};
|
|
5337
5312
|
var extractFingerprintArg = (launchOptions = {}) => {
|
|
5338
5313
|
const args = Array.isArray(launchOptions?.args) ? launchOptions.args : [];
|
|
5339
5314
|
return args.find((value) => String(value || "").startsWith("--fingerprint=")) || "";
|
|
5340
5315
|
};
|
|
5341
5316
|
var createStableGotoHook = (recommendedGotoOptions = DEFAULT_CLOAK_GOTO_OPTIONS) => {
|
|
5342
|
-
const normalizedRecommendedGotoOptions =
|
|
5317
|
+
const normalizedRecommendedGotoOptions = normalizeObject2(recommendedGotoOptions);
|
|
5343
5318
|
const fallbackGotoOptions = Object.keys(normalizedRecommendedGotoOptions).length > 0 ? normalizedRecommendedGotoOptions : DEFAULT_CLOAK_GOTO_OPTIONS;
|
|
5344
5319
|
return async (_crawlingContext, gotoOptions = {}) => {
|
|
5345
5320
|
for (const [key, value] of Object.entries(fallbackGotoOptions)) {
|
|
@@ -5355,11 +5330,11 @@ var attachCloakHumanizeHook = ({
|
|
|
5355
5330
|
patchedBrowsers,
|
|
5356
5331
|
humanizeOptions = DEFAULT_CLOAK_HUMANIZE_OPTIONS
|
|
5357
5332
|
} = {}) => {
|
|
5358
|
-
const normalizedBrowserPoolOptions =
|
|
5333
|
+
const normalizedBrowserPoolOptions = normalizeObject2(browserPoolOptions);
|
|
5359
5334
|
const shouldHumanize = humanizeOptions !== false;
|
|
5360
5335
|
const normalizedHumanizeOptions = shouldHumanize ? {
|
|
5361
5336
|
...DEFAULT_CLOAK_HUMANIZE_OPTIONS,
|
|
5362
|
-
...
|
|
5337
|
+
...normalizeObject2(humanizeOptions)
|
|
5363
5338
|
} : null;
|
|
5364
5339
|
return {
|
|
5365
5340
|
...normalizedBrowserPoolOptions,
|
|
@@ -5408,7 +5383,7 @@ var forceTerminateBrowsersByFingerprintArg = async (fingerprintArg) => {
|
|
|
5408
5383
|
if (error?.code === 1 || error?.code === "ENOENT") {
|
|
5409
5384
|
return;
|
|
5410
5385
|
}
|
|
5411
|
-
|
|
5386
|
+
logger9.info(`\u5F3A\u5236\u5173\u95ED Cloak \u8FDB\u7A0B\u5931\u8D25\uFF08\u5FFD\u7565\uFF09: ${error?.message || String(error)}`);
|
|
5412
5387
|
});
|
|
5413
5388
|
};
|
|
5414
5389
|
var CloakLaunch = {
|
|
@@ -5442,7 +5417,7 @@ var CloakLaunch = {
|
|
|
5442
5417
|
return await buildCloakLaunchOptions(options);
|
|
5443
5418
|
},
|
|
5444
5419
|
async createPlaywrightCrawlerRuntime(options = {}) {
|
|
5445
|
-
const normalizedOptions =
|
|
5420
|
+
const normalizedOptions = normalizeObject2(options);
|
|
5446
5421
|
const {
|
|
5447
5422
|
proxyConfiguration = {},
|
|
5448
5423
|
log: logOptions = null,
|
|
@@ -5459,17 +5434,13 @@ var CloakLaunch = {
|
|
|
5459
5434
|
postNavigationHooks = [],
|
|
5460
5435
|
recommendedGotoOptions = DEFAULT_CLOAK_GOTO_OPTIONS
|
|
5461
5436
|
} = normalizedOptions;
|
|
5462
|
-
const normalizedCloakOptions =
|
|
5437
|
+
const normalizedCloakOptions = normalizeObject2(cloakOptions);
|
|
5463
5438
|
const activeBrowsers = /* @__PURE__ */ new Set();
|
|
5464
5439
|
const patchedBrowsers = /* @__PURE__ */ new WeakSet();
|
|
5465
5440
|
const defaultArgs = isRunningOnApify ? ["--no-sandbox", "--disable-setuid-sandbox"] : [];
|
|
5466
5441
|
const extraArgs = normalizeStringArray(normalizedCloakOptions.args);
|
|
5467
5442
|
const hasExplicitProxy = hasOwn(normalizedCloakOptions, "proxy");
|
|
5468
|
-
const proxyLaunchState = hasExplicitProxy ? {
|
|
5469
|
-
...resolveProxyLaunchOptions2(proxyConfiguration),
|
|
5470
|
-
byPassRules: [],
|
|
5471
|
-
launchProxy: null
|
|
5472
|
-
} : buildMeteredProxy({ proxyConfiguration, debugMode });
|
|
5443
|
+
const proxyLaunchState = hasExplicitProxy ? resolveLaunchTraffic({ proxyConfiguration, debugMode, useMeter: false }) : resolveLaunchTraffic({ proxyConfiguration, debugMode });
|
|
5473
5444
|
const proxy = hasExplicitProxy ? normalizedCloakOptions.proxy : proxyLaunchState.launchProxy;
|
|
5474
5445
|
const headless = hasOwn(normalizedCloakOptions, "headless") ? normalizedCloakOptions.headless : !runInHeadfulMode || isRunningOnApify;
|
|
5475
5446
|
const enableByPassLogger = Boolean(logOptions && logOptions.enable);
|
|
@@ -5482,30 +5453,27 @@ var CloakLaunch = {
|
|
|
5482
5453
|
const launchOptions = await buildCloakLaunchOptions(mergedCloakOptions);
|
|
5483
5454
|
const fingerprintArg = extractFingerprintArg(launchOptions);
|
|
5484
5455
|
const internalPreNavigationHook = createStableGotoHook(recommendedGotoOptions);
|
|
5485
|
-
const
|
|
5456
|
+
const trafficHook = createLaunchTrafficHook({
|
|
5486
5457
|
byPassDomains: proxyLaunchState.byPassDomains,
|
|
5487
5458
|
byPassRules: proxyLaunchState.byPassRules,
|
|
5488
|
-
enableByPassLogger,
|
|
5459
|
+
enabled: enableByPassLogger,
|
|
5489
5460
|
launchProxy: proxyLaunchState.launchProxy
|
|
5490
5461
|
});
|
|
5491
5462
|
const normalizedPreNavigationHooks = Array.isArray(preNavigationHooks) ? preNavigationHooks : [];
|
|
5492
5463
|
const normalizedPostNavigationHooks = Array.isArray(postNavigationHooks) ? postNavigationHooks : [];
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
enableByPassLogger
|
|
5500
|
-
});
|
|
5501
|
-
}
|
|
5464
|
+
logLaunchTraffic({
|
|
5465
|
+
...proxyLaunchState,
|
|
5466
|
+
debugMode,
|
|
5467
|
+
enabled: enableByPassLogger,
|
|
5468
|
+
explicitProxy: hasExplicitProxy
|
|
5469
|
+
});
|
|
5502
5470
|
const crawlerOptions = {
|
|
5503
5471
|
...DEFAULT_CLOAK_CRAWLER_BASE_OPTIONS,
|
|
5504
|
-
...
|
|
5472
|
+
...normalizeObject2(crawlerBaseOptions),
|
|
5505
5473
|
headless,
|
|
5506
5474
|
launchContext: {
|
|
5507
5475
|
useIncognitoPages: true,
|
|
5508
|
-
...
|
|
5476
|
+
...normalizeObject2(launchContext),
|
|
5509
5477
|
...launcher ? { launcher } : {},
|
|
5510
5478
|
launchOptions
|
|
5511
5479
|
},
|
|
@@ -5517,7 +5485,7 @@ var CloakLaunch = {
|
|
|
5517
5485
|
}),
|
|
5518
5486
|
preNavigationHooks: [
|
|
5519
5487
|
async (crawlingContext, gotoOptions = {}) => {
|
|
5520
|
-
|
|
5488
|
+
trafficHook(crawlingContext?.page);
|
|
5521
5489
|
await internalPreNavigationHook(crawlingContext, gotoOptions);
|
|
5522
5490
|
},
|
|
5523
5491
|
...normalizedPreNavigationHooks
|
|
@@ -5556,7 +5524,7 @@ var Launch = withModeReflect("Launch", launchStrategies);
|
|
|
5556
5524
|
// src/live-view.js
|
|
5557
5525
|
import express from "express";
|
|
5558
5526
|
import { Actor } from "apify";
|
|
5559
|
-
var
|
|
5527
|
+
var logger10 = createInternalLogger("LiveView");
|
|
5560
5528
|
async function startLiveViewServer(liveViewKey) {
|
|
5561
5529
|
const app = express();
|
|
5562
5530
|
app.get("/", async (req, res) => {
|
|
@@ -5581,13 +5549,13 @@ async function startLiveViewServer(liveViewKey) {
|
|
|
5581
5549
|
</html>
|
|
5582
5550
|
`);
|
|
5583
5551
|
} catch (error) {
|
|
5584
|
-
|
|
5552
|
+
logger10.fail("Live View Server", error);
|
|
5585
5553
|
res.status(500).send(`\u65E0\u6CD5\u52A0\u8F7D\u5C4F\u5E55\u622A\u56FE: ${error.message}`);
|
|
5586
5554
|
}
|
|
5587
5555
|
});
|
|
5588
5556
|
const port = process.env.APIFY_CONTAINER_PORT || 4321;
|
|
5589
5557
|
app.listen(port, () => {
|
|
5590
|
-
|
|
5558
|
+
logger10.success("startLiveViewServer", `\u76D1\u542C\u7AEF\u53E3 ${port}`);
|
|
5591
5559
|
});
|
|
5592
5560
|
}
|
|
5593
5561
|
async function takeLiveScreenshot(liveViewKey, page, logMessage) {
|
|
@@ -5595,10 +5563,10 @@ async function takeLiveScreenshot(liveViewKey, page, logMessage) {
|
|
|
5595
5563
|
const buffer = await capturePageScreenshot(page, { type: "png" });
|
|
5596
5564
|
await Actor.setValue(liveViewKey, buffer, { contentType: "image/png" });
|
|
5597
5565
|
if (logMessage) {
|
|
5598
|
-
|
|
5566
|
+
logger10.info(`(\u622A\u56FE): ${logMessage}`);
|
|
5599
5567
|
}
|
|
5600
5568
|
} catch (e) {
|
|
5601
|
-
|
|
5569
|
+
logger10.warn(`\u65E0\u6CD5\u6355\u83B7 Live View \u5C4F\u5E55\u622A\u56FE: ${e.message}`);
|
|
5602
5570
|
}
|
|
5603
5571
|
}
|
|
5604
5572
|
var useLiveView = (liveViewKey = PresetOfLiveViewKey) => {
|
|
@@ -5707,7 +5675,7 @@ var dragCaptchaAction = async (page, sourceLocator, targetLocator, options = {})
|
|
|
5707
5675
|
};
|
|
5708
5676
|
|
|
5709
5677
|
// src/internals/captcha/bytedance.js
|
|
5710
|
-
var
|
|
5678
|
+
var logger11 = createInternalLogger("Captcha");
|
|
5711
5679
|
var DEFAULT_BYTEDANCE_CAPTCHA_OPTIONS = Object.freeze({
|
|
5712
5680
|
apiType: "31234",
|
|
5713
5681
|
maxRetries: 3,
|
|
@@ -5839,7 +5807,7 @@ var collectCaptchaDebugInfo = async (page, frame, iframeLocator, attempt, phase,
|
|
|
5839
5807
|
}
|
|
5840
5808
|
await writeFile(infoPath, JSON.stringify(payload, null, 2), "utf8");
|
|
5841
5809
|
}
|
|
5842
|
-
|
|
5810
|
+
logger11.info(`\u5DF2\u5199\u51FA\u9A8C\u8BC1\u7801\u8C03\u8BD5\u4EA7\u7269\uFF1A${debugDir}`);
|
|
5843
5811
|
};
|
|
5844
5812
|
var maybeCollectCaptchaDebugInfo = async (page, frame, iframeLocator, attempt, phase, options, extra = null) => {
|
|
5845
5813
|
if (!options.debugArtifacts) {
|
|
@@ -5876,14 +5844,14 @@ var getVerifycenterCaptchaContext = async (page, options) => {
|
|
|
5876
5844
|
if (!isContainerVisible) {
|
|
5877
5845
|
return null;
|
|
5878
5846
|
}
|
|
5879
|
-
|
|
5847
|
+
logger11.info("\u68C0\u6D4B\u5230\u9A8C\u8BC1\u7801\u5BB9\u5668\uFF0C\u5F00\u59CB\u7B49\u5F85 iframe \u52A0\u8F7D\u3002");
|
|
5880
5848
|
let iframeLocator = page.locator(options.iframeSelector).first();
|
|
5881
5849
|
let isIframeVisible = await waitForVisible(
|
|
5882
5850
|
iframeLocator,
|
|
5883
5851
|
options.iframeVisibleTimeoutMs
|
|
5884
5852
|
);
|
|
5885
5853
|
if (!isIframeVisible) {
|
|
5886
|
-
|
|
5854
|
+
logger11.warn("\u672A\u5728\u9884\u671F\u9009\u62E9\u5668\u4E2D\u627E\u5230 verifycenter iframe\uFF0C\u5C1D\u8BD5\u5BB9\u5668\u5185\u4EFB\u610F iframe\u3002");
|
|
5887
5855
|
iframeLocator = captchaContainer.locator(options.iframeFallbackSelector).first();
|
|
5888
5856
|
isIframeVisible = await waitForVisible(
|
|
5889
5857
|
iframeLocator,
|
|
@@ -5893,7 +5861,7 @@ var getVerifycenterCaptchaContext = async (page, options) => {
|
|
|
5893
5861
|
if (!isIframeVisible) {
|
|
5894
5862
|
throw new Error("verifycenter iframe not found inside captcha container.");
|
|
5895
5863
|
}
|
|
5896
|
-
|
|
5864
|
+
logger11.info("\u9A8C\u8BC1\u7801 iframe \u5DF2\u53EF\u89C1\uFF0C\u5F00\u59CB\u89E3\u6790\u5185\u5BB9 frame\u3002");
|
|
5897
5865
|
const frame = await resolveContentFrame(page, iframeLocator, options);
|
|
5898
5866
|
if (!frame) {
|
|
5899
5867
|
throw new Error("Failed to resolve verifycenter iframe content frame.");
|
|
@@ -6009,11 +5977,11 @@ var refreshCaptcha = async (page, frame, options) => {
|
|
|
6009
5977
|
const clicked = await clickCaptchaAction(frame, options.refreshTexts, {
|
|
6010
5978
|
...options,
|
|
6011
5979
|
page,
|
|
6012
|
-
logger:
|
|
5980
|
+
logger: logger11,
|
|
6013
5981
|
forceMouse: true
|
|
6014
5982
|
}).catch(() => false);
|
|
6015
5983
|
if (!clicked) {
|
|
6016
|
-
|
|
5984
|
+
logger11.warn("Refresh button not found.");
|
|
6017
5985
|
return false;
|
|
6018
5986
|
}
|
|
6019
5987
|
await page.waitForTimeout(options.refreshWaitMs);
|
|
@@ -6044,24 +6012,24 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
|
|
|
6044
6012
|
const hasGuideMaskVisible = options.guideMaskSelector ? await frame.locator(options.guideMaskSelector).first().isVisible({ timeout: options.loadingIndicatorVisibleTimeoutMs }).catch(() => false) : false;
|
|
6045
6013
|
hasSeenGuideMask = hasSeenGuideMask || hasGuideMaskVisible;
|
|
6046
6014
|
if (hasGuideMaskVisible && !hasLoggedGuideMask) {
|
|
6047
|
-
|
|
6015
|
+
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");
|
|
6048
6016
|
hasLoggedGuideMask = true;
|
|
6049
6017
|
}
|
|
6050
6018
|
if (!isLoadingVisible && hasVisibleSourceImage && hasVisibleDropTarget && !hasGuideMaskVisible) {
|
|
6051
|
-
|
|
6019
|
+
logger11.info(
|
|
6052
6020
|
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"
|
|
6053
6021
|
);
|
|
6054
6022
|
return;
|
|
6055
6023
|
}
|
|
6056
6024
|
if (hasErrorTextVisible) {
|
|
6057
|
-
|
|
6025
|
+
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");
|
|
6058
6026
|
await refreshCaptcha(page, frame, options);
|
|
6059
6027
|
refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
|
|
6060
6028
|
hasSeenLoading = false;
|
|
6061
6029
|
continue;
|
|
6062
6030
|
}
|
|
6063
6031
|
if ((!hasVisibleSourceImage || !hasVisibleDropTarget) && Date.now() >= refreshDeadline) {
|
|
6064
|
-
|
|
6032
|
+
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`);
|
|
6065
6033
|
await refreshCaptcha(page, frame, options);
|
|
6066
6034
|
refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
|
|
6067
6035
|
hasSeenLoading = false;
|
|
@@ -6109,7 +6077,7 @@ var dragPromptCaptchaImage = async (page, frame, iframeLocator, sourceLocator, d
|
|
|
6109
6077
|
accepted
|
|
6110
6078
|
};
|
|
6111
6079
|
dragAttempts.push(attemptInfo);
|
|
6112
|
-
|
|
6080
|
+
logger11.info(
|
|
6113
6081
|
`\u9A8C\u8BC1\u7801\u62D6\u62FD\u7B2C ${visualIndex + 1} \u5F20\uFF0C\u65B9\u6848 ${plan.name}\uFF0Cbadge ${baselineState.badgeCount} -> ${afterState.badgeCount}\uFF0Cselected ${baselineState.selectedCount} -> ${afterState.selectedCount}`
|
|
6114
6082
|
);
|
|
6115
6083
|
if (accepted) {
|
|
@@ -6127,7 +6095,7 @@ var dragPromptCaptchaImage = async (page, frame, iframeLocator, sourceLocator, d
|
|
|
6127
6095
|
dragAttempts,
|
|
6128
6096
|
finalState: await readPromptCaptchaState(frame, options)
|
|
6129
6097
|
}).catch((error) => {
|
|
6130
|
-
|
|
6098
|
+
logger11.warn(`\u9A8C\u8BC1\u7801\u62D6\u62FD\u5931\u8D25\u8C03\u8BD5\u6293\u53D6\u5931\u8D25\uFF1A${error?.message || error}`);
|
|
6131
6099
|
});
|
|
6132
6100
|
return {
|
|
6133
6101
|
accepted: false,
|
|
@@ -6144,16 +6112,16 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6144
6112
|
...options
|
|
6145
6113
|
};
|
|
6146
6114
|
if (!config.token) {
|
|
6147
|
-
|
|
6115
|
+
logger11.warn("\u7F3A\u5C11\u9A8C\u8BC1\u7801 token\uFF0C\u8DF3\u8FC7\u81EA\u52A8\u8BC6\u522B\u3002");
|
|
6148
6116
|
return false;
|
|
6149
6117
|
}
|
|
6150
|
-
|
|
6118
|
+
logger11.info("\u5F53\u524D\u4F7F\u7528\u672Ctool\u2014\u2014\u6D4B\u8BD5\u7248\u672C");
|
|
6151
6119
|
for (let attempt = 1; attempt <= config.maxRetries; attempt += 1) {
|
|
6152
|
-
|
|
6120
|
+
logger11.info(`\u5F00\u59CB\u7B2C ${attempt}/${config.maxRetries} \u6B21 verifycenter \u9A8C\u8BC1\u7801\u8BC6\u522B\u3002`);
|
|
6153
6121
|
try {
|
|
6154
6122
|
const captchaContext = await getVerifycenterCaptchaContext(page, config);
|
|
6155
6123
|
if (!captchaContext) {
|
|
6156
|
-
|
|
6124
|
+
logger11.info("Captcha container is not visible anymore.");
|
|
6157
6125
|
return true;
|
|
6158
6126
|
}
|
|
6159
6127
|
const { iframeLocator, frame } = captchaContext;
|
|
@@ -6166,7 +6134,7 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6166
6134
|
"ready",
|
|
6167
6135
|
config
|
|
6168
6136
|
).catch((error) => {
|
|
6169
|
-
|
|
6137
|
+
logger11.warn(`\u9A8C\u8BC1\u7801\u8C03\u8BD5\u6293\u53D6\u5931\u8D25\uFF1A${error?.message || error}`);
|
|
6170
6138
|
});
|
|
6171
6139
|
await page.waitForTimeout(config.recognitionDelayMs);
|
|
6172
6140
|
const screenshotBuffer = await iframeLocator.screenshot();
|
|
@@ -6178,16 +6146,16 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6178
6146
|
});
|
|
6179
6147
|
const serialNumbers = extractCaptchaSerialNumbers(apiResponse);
|
|
6180
6148
|
if (apiResponse?.code !== config.recognitionSuccessCode || serialNumbers.length === 0) {
|
|
6181
|
-
|
|
6149
|
+
logger11.warn(
|
|
6182
6150
|
`\u9A8C\u8BC1\u7801\u8BC6\u522B\u5931\u8D25\u3002code=${apiResponse?.code}, msg=${apiResponse?.msg || "unknown"}`
|
|
6183
6151
|
);
|
|
6184
6152
|
await refreshCaptcha(page, frame, config);
|
|
6185
6153
|
continue;
|
|
6186
6154
|
}
|
|
6187
|
-
|
|
6155
|
+
logger11.info(`\u9A8C\u8BC1\u7801\u8BC6\u522B\u6210\u529F\uFF0C\u5E8F\u53F7\uFF1A${serialNumbers.join(", ")}`);
|
|
6188
6156
|
const dropTarget = await findCaptchaDropTarget(frame, config);
|
|
6189
6157
|
if (!dropTarget) {
|
|
6190
|
-
|
|
6158
|
+
logger11.warn("\u672A\u627E\u5230\u9A8C\u8BC1\u7801\u62D6\u62FD\u76EE\u6807\u533A\u57DF\u3002");
|
|
6191
6159
|
await refreshCaptcha(page, frame, config);
|
|
6192
6160
|
continue;
|
|
6193
6161
|
}
|
|
@@ -6198,7 +6166,7 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6198
6166
|
`Captcha image indexes could not be normalized. raw=${serialNumbers.join(", ")}, count=${orderedSourceImages.length}`
|
|
6199
6167
|
);
|
|
6200
6168
|
}
|
|
6201
|
-
|
|
6169
|
+
logger11.info(`\u9A8C\u8BC1\u7801\u89C6\u89C9\u4F4D\u5E8F\u6620\u5C04\uFF1A${normalizedIndexes.map((index) => index + 1).join(", ")}`);
|
|
6202
6170
|
for (const imageIndex of normalizedIndexes) {
|
|
6203
6171
|
if (imageIndex < 0 || imageIndex >= orderedSourceImages.length) {
|
|
6204
6172
|
throw new Error(
|
|
@@ -6230,52 +6198,52 @@ async function solveCaptcha(page, options = {}, dependencies = {}) {
|
|
|
6230
6198
|
}
|
|
6231
6199
|
}
|
|
6232
6200
|
const beforeSubmitState = await readPromptCaptchaState(frame, config);
|
|
6233
|
-
|
|
6201
|
+
logger11.info(
|
|
6234
6202
|
`\u63D0\u4EA4\u524D\u9A8C\u8BC1\u7801\u72B6\u6001\uFF1Abadge=${beforeSubmitState.badgeCount}, selected=${beforeSubmitState.selectedCount}, submitDisabled=${beforeSubmitState.submitDisabled}`
|
|
6235
6203
|
);
|
|
6236
6204
|
const submitted = await clickCaptchaAction(frame, config.submitTexts, {
|
|
6237
6205
|
...config,
|
|
6238
6206
|
page,
|
|
6239
|
-
logger:
|
|
6207
|
+
logger: logger11,
|
|
6240
6208
|
forceMouse: true,
|
|
6241
6209
|
actionVisibleTimeoutMs: config.submitReadyTimeoutMs
|
|
6242
6210
|
}).catch(() => false);
|
|
6243
6211
|
if (!submitted) {
|
|
6244
|
-
|
|
6212
|
+
logger11.warn("\u672A\u627E\u5230\u63D0\u4EA4\u6309\u94AE\uFF0C\u53EF\u80FD\u4F1A\u81EA\u52A8\u63D0\u4EA4\u3002");
|
|
6245
6213
|
}
|
|
6246
6214
|
await page.waitForTimeout(config.submitWaitMs);
|
|
6247
6215
|
const afterSubmitState = await readPromptCaptchaState(frame, config);
|
|
6248
|
-
|
|
6216
|
+
logger11.info(
|
|
6249
6217
|
`\u63D0\u4EA4\u540E\u9A8C\u8BC1\u7801\u72B6\u6001\uFF1Abadge=${afterSubmitState.badgeCount}, selected=${afterSubmitState.selectedCount}, submitDisabled=${afterSubmitState.submitDisabled}`
|
|
6250
6218
|
);
|
|
6251
6219
|
const stillVisible = await iframeLocator.isVisible({ timeout: config.containerVisibleTimeoutMs }).catch(() => false);
|
|
6252
6220
|
if (!stillVisible) {
|
|
6253
|
-
|
|
6221
|
+
logger11.info("\u9A8C\u8BC1\u7801\u8BC6\u522B\u5E76\u63D0\u4EA4\u6210\u529F\u3002");
|
|
6254
6222
|
return true;
|
|
6255
6223
|
}
|
|
6256
6224
|
await maybeCollectCaptchaDebugInfo(page, frame, iframeLocator, attempt, "submit-still-visible", config, {
|
|
6257
6225
|
beforeSubmitState,
|
|
6258
6226
|
afterSubmitState
|
|
6259
6227
|
}).catch((error) => {
|
|
6260
|
-
|
|
6228
|
+
logger11.warn(`\u63D0\u4EA4\u540E\u9A8C\u8BC1\u7801\u8C03\u8BD5\u6293\u53D6\u5931\u8D25\uFF1A${error?.message || error}`);
|
|
6261
6229
|
});
|
|
6262
|
-
|
|
6230
|
+
logger11.warn("\u63D0\u4EA4\u540E\u9A8C\u8BC1\u7801 iframe \u4ECD\u7136\u53EF\u89C1\uFF0C\u51C6\u5907\u5237\u65B0\u540E\u91CD\u8BD5\u3002");
|
|
6263
6231
|
await page.waitForTimeout(2e3);
|
|
6264
6232
|
await refreshCaptcha(page, frame, config);
|
|
6265
6233
|
} catch (error) {
|
|
6266
|
-
|
|
6234
|
+
logger11.error(`\u7B2C ${attempt}/${config.maxRetries} \u6B21\u9A8C\u8BC1\u7801\u8BC6\u522B\u5931\u8D25\uFF1A${error?.message || error}`);
|
|
6267
6235
|
}
|
|
6268
6236
|
if (attempt < config.maxRetries) {
|
|
6269
6237
|
await page.waitForTimeout(config.retryDelayBaseMs + attempt * config.retryDelayStepMs);
|
|
6270
6238
|
}
|
|
6271
6239
|
}
|
|
6272
|
-
|
|
6240
|
+
logger11.error(`\u91CD\u8BD5 ${config.maxRetries} \u6B21\u540E\uFF0C\u9A8C\u8BC1\u7801\u4ECD\u672A\u8BC6\u522B\u6210\u529F\u3002`);
|
|
6273
6241
|
return false;
|
|
6274
6242
|
}
|
|
6275
6243
|
var sloveCaptcha = solveCaptcha;
|
|
6276
6244
|
|
|
6277
6245
|
// src/chaptcha.js
|
|
6278
|
-
var
|
|
6246
|
+
var logger12 = createInternalLogger("Captcha");
|
|
6279
6247
|
var DEFAULT_CAPTCHA_RECOGNITION_OPTIONS = Object.freeze({
|
|
6280
6248
|
token: "eKJvBfwfN0YRav0-VD_44E2VBSfm7l0YtddUQ7cFySI",
|
|
6281
6249
|
apiUrl: "https://api.jfbym.com/api/YmServer/customApi"
|
|
@@ -6362,7 +6330,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
6362
6330
|
};
|
|
6363
6331
|
})();
|
|
6364
6332
|
}, { selector: domSelector, callbackName: exposedFunctionName, cleanerName });
|
|
6365
|
-
|
|
6333
|
+
logger12.success("useCaptchaMonitor", `DOM \u76D1\u63A7\u5DF2\u542F\u7528\uFF1A${domSelector}`);
|
|
6366
6334
|
cleanupFns.push(async () => {
|
|
6367
6335
|
try {
|
|
6368
6336
|
await page.evaluate((name) => {
|
|
@@ -6386,14 +6354,14 @@ function useCaptchaMonitor(page, options) {
|
|
|
6386
6354
|
}
|
|
6387
6355
|
};
|
|
6388
6356
|
page.on("framenavigated", frameHandler);
|
|
6389
|
-
|
|
6357
|
+
logger12.success("useCaptchaMonitor", `URL \u76D1\u63A7\u5DF2\u542F\u7528\uFF1A${urlPattern}`);
|
|
6390
6358
|
cleanupFns.push(async () => {
|
|
6391
6359
|
page.off("framenavigated", frameHandler);
|
|
6392
6360
|
});
|
|
6393
6361
|
}
|
|
6394
6362
|
return {
|
|
6395
6363
|
stop: async () => {
|
|
6396
|
-
|
|
6364
|
+
logger12.info("\u6B63\u5728\u505C\u6B62\u9A8C\u8BC1\u7801\u76D1\u63A7...");
|
|
6397
6365
|
for (const fn of cleanupFns) {
|
|
6398
6366
|
await fn();
|
|
6399
6367
|
}
|
|
@@ -6432,7 +6400,7 @@ async function solveCaptchaWithStrategy(strategyName, page, options = {}) {
|
|
|
6432
6400
|
);
|
|
6433
6401
|
return strategy.sloveCaptcha(page, resolvedOptions, {
|
|
6434
6402
|
callCaptchaRecognitionApi,
|
|
6435
|
-
logger:
|
|
6403
|
+
logger: logger12
|
|
6436
6404
|
});
|
|
6437
6405
|
}
|
|
6438
6406
|
var Captcha = {
|
|
@@ -6443,7 +6411,7 @@ var Captcha = {
|
|
|
6443
6411
|
// src/mutation.js
|
|
6444
6412
|
import { createHash } from "node:crypto";
|
|
6445
6413
|
import { v4 as uuidv42 } from "uuid";
|
|
6446
|
-
var
|
|
6414
|
+
var logger13 = createInternalLogger("Mutation");
|
|
6447
6415
|
var MUTATION_MONITOR_MODE = Object.freeze({
|
|
6448
6416
|
Added: "added",
|
|
6449
6417
|
Changed: "changed",
|
|
@@ -6476,14 +6444,14 @@ var Mutation = {
|
|
|
6476
6444
|
const stableTime = options.stableTime ?? 5 * 1e3;
|
|
6477
6445
|
const timeout = options.timeout ?? 120 * 1e3;
|
|
6478
6446
|
const onMutation = options.onMutation;
|
|
6479
|
-
|
|
6447
|
+
logger13.start("waitForStable", `\u76D1\u63A7 ${selectorList.length} \u4E2A\u9009\u62E9\u5668, \u7A33\u5B9A\u65F6\u95F4=${stableTime}ms`);
|
|
6480
6448
|
if (initialTimeout > 0) {
|
|
6481
6449
|
const selectorQuery = selectorList.join(",");
|
|
6482
6450
|
try {
|
|
6483
6451
|
await page.waitForSelector(selectorQuery, { timeout: initialTimeout });
|
|
6484
|
-
|
|
6452
|
+
logger13.info(`waitForStable \u5DF2\u68C0\u6D4B\u5230\u5143\u7D20: ${selectorQuery}`);
|
|
6485
6453
|
} catch (e) {
|
|
6486
|
-
|
|
6454
|
+
logger13.warning(`waitForStable \u521D\u59CB\u7B49\u5F85\u8D85\u65F6 (${initialTimeout}ms): ${selectorQuery}`);
|
|
6487
6455
|
throw e;
|
|
6488
6456
|
}
|
|
6489
6457
|
}
|
|
@@ -6499,7 +6467,7 @@ var Mutation = {
|
|
|
6499
6467
|
return "__CONTINUE__";
|
|
6500
6468
|
}
|
|
6501
6469
|
});
|
|
6502
|
-
|
|
6470
|
+
logger13.info("waitForStable \u5DF2\u542F\u7528 onMutation \u56DE\u8C03");
|
|
6503
6471
|
} catch (e) {
|
|
6504
6472
|
}
|
|
6505
6473
|
}
|
|
@@ -6614,9 +6582,9 @@ var Mutation = {
|
|
|
6614
6582
|
{ selectorList, stableTime, timeout, callbackName, hasCallback: !!onMutation }
|
|
6615
6583
|
);
|
|
6616
6584
|
if (result.mutationCount === 0 && result.stableTime === 0) {
|
|
6617
|
-
|
|
6585
|
+
logger13.warning("waitForStable \u672A\u627E\u5230\u53EF\u76D1\u63A7\u7684\u5143\u7D20");
|
|
6618
6586
|
}
|
|
6619
|
-
|
|
6587
|
+
logger13.success("waitForStable", `DOM \u7A33\u5B9A, \u603B\u5171 ${result.mutationCount} \u6B21\u53D8\u5316${result.wasPaused ? ", \u66FE\u6682\u505C\u8BA1\u65F6" : ""}`);
|
|
6620
6588
|
return result;
|
|
6621
6589
|
},
|
|
6622
6590
|
/**
|
|
@@ -6788,22 +6756,22 @@ var Mutation = {
|
|
|
6788
6756
|
return "__CONTINUE__";
|
|
6789
6757
|
}
|
|
6790
6758
|
};
|
|
6791
|
-
|
|
6759
|
+
logger13.start(
|
|
6792
6760
|
"waitForStableAcrossRoots",
|
|
6793
6761
|
`\u76D1\u63A7 ${selectorList.length} \u4E2A\u9009\u62E9\u5668(\u8DE8 root), \u7A33\u5B9A\u65F6\u95F4=${waitForStableTime}ms`
|
|
6794
6762
|
);
|
|
6795
6763
|
if (initialTimeout > 0) {
|
|
6796
6764
|
try {
|
|
6797
6765
|
await page.waitForSelector(selectorQuery, { timeout: initialTimeout });
|
|
6798
|
-
|
|
6766
|
+
logger13.info(`waitForStableAcrossRoots \u5DF2\u68C0\u6D4B\u5230\u5143\u7D20: ${selectorQuery}`);
|
|
6799
6767
|
} catch (e) {
|
|
6800
|
-
|
|
6768
|
+
logger13.warning(`waitForStableAcrossRoots \u521D\u59CB\u7B49\u5F85\u8D85\u65F6 (${initialTimeout}ms): ${selectorQuery}`);
|
|
6801
6769
|
throw e;
|
|
6802
6770
|
}
|
|
6803
6771
|
}
|
|
6804
6772
|
let state2 = await buildState();
|
|
6805
6773
|
if (!state2?.hasMatched) {
|
|
6806
|
-
|
|
6774
|
+
logger13.warning("waitForStableAcrossRoots \u672A\u627E\u5230\u53EF\u76D1\u63A7\u7684\u5143\u7D20");
|
|
6807
6775
|
return { mutationCount: 0, stableTime: 0, wasPaused: false };
|
|
6808
6776
|
}
|
|
6809
6777
|
let mutationCount = 0;
|
|
@@ -6840,7 +6808,7 @@ var Mutation = {
|
|
|
6840
6808
|
if (lastState.snapshotKey !== lastSnapshotKey) {
|
|
6841
6809
|
lastSnapshotKey = lastState.snapshotKey;
|
|
6842
6810
|
mutationCount += 1;
|
|
6843
|
-
|
|
6811
|
+
logger13.info(
|
|
6844
6812
|
`waitForStableAcrossRoots \u53D8\u5316#${mutationCount}, len=${lastState.snapshotLength}, path=${lastState.primaryPath || "unknown"}, preview="${truncate(lastState.text, 120)}"`
|
|
6845
6813
|
);
|
|
6846
6814
|
const signal = await invokeMutationCallback({
|
|
@@ -6853,7 +6821,7 @@ var Mutation = {
|
|
|
6853
6821
|
continue;
|
|
6854
6822
|
}
|
|
6855
6823
|
if (!isPaused && stableSince > 0 && Date.now() - stableSince >= waitForStableTime) {
|
|
6856
|
-
|
|
6824
|
+
logger13.success("waitForStableAcrossRoots", `DOM \u7A33\u5B9A, \u603B\u5171 ${mutationCount} \u6B21\u53D8\u5316${wasPaused ? ", \u66FE\u6682\u505C\u8BA1\u65F6" : ""}`);
|
|
6857
6825
|
return {
|
|
6858
6826
|
mutationCount,
|
|
6859
6827
|
stableTime: waitForStableTime,
|
|
@@ -6880,7 +6848,7 @@ var Mutation = {
|
|
|
6880
6848
|
const onMutation = options.onMutation;
|
|
6881
6849
|
const rawMode = String(options.mode || MUTATION_MONITOR_MODE.Added).toLowerCase();
|
|
6882
6850
|
const mode = [MUTATION_MONITOR_MODE.Added, MUTATION_MONITOR_MODE.Changed, MUTATION_MONITOR_MODE.All].includes(rawMode) ? rawMode : MUTATION_MONITOR_MODE.Added;
|
|
6883
|
-
|
|
6851
|
+
logger13.start("useMonitor", `\u76D1\u63A7 ${selectorList.length} \u4E2A\u9009\u62E9\u5668, mode=${mode}`);
|
|
6884
6852
|
const monitorKey = generateKey("pk_mon");
|
|
6885
6853
|
const callbackName = generateKey("pk_mon_cb");
|
|
6886
6854
|
const cleanerName = generateKey("pk_mon_clean");
|
|
@@ -7023,7 +6991,7 @@ var Mutation = {
|
|
|
7023
6991
|
return total;
|
|
7024
6992
|
};
|
|
7025
6993
|
}, { selectorList, monitorKey, callbackName, cleanerName, hasCallback: !!onMutation, mode });
|
|
7026
|
-
|
|
6994
|
+
logger13.success("useMonitor", "\u76D1\u63A7\u5668\u5DF2\u542F\u52A8");
|
|
7027
6995
|
return {
|
|
7028
6996
|
stop: async () => {
|
|
7029
6997
|
let totalMutations = 0;
|
|
@@ -7036,7 +7004,7 @@ var Mutation = {
|
|
|
7036
7004
|
}, cleanerName);
|
|
7037
7005
|
} catch (e) {
|
|
7038
7006
|
}
|
|
7039
|
-
|
|
7007
|
+
logger13.success("useMonitor.stop", `\u76D1\u63A7\u5DF2\u505C\u6B62, \u5171 ${totalMutations} \u6B21\u53D8\u5316`);
|
|
7040
7008
|
return { totalMutations };
|
|
7041
7009
|
}
|
|
7042
7010
|
};
|
|
@@ -7905,7 +7873,7 @@ var createTemplateLogger = (baseLogger = createBaseLogger()) => {
|
|
|
7905
7873
|
};
|
|
7906
7874
|
var getDefaultBaseLogger = () => createBaseLogger("");
|
|
7907
7875
|
var Logger = {
|
|
7908
|
-
setLogger: (
|
|
7876
|
+
setLogger: (logger17) => setDefaultLogger(logger17),
|
|
7909
7877
|
info: (message) => getDefaultBaseLogger().info(message),
|
|
7910
7878
|
success: (message) => getDefaultBaseLogger().success(message),
|
|
7911
7879
|
warning: (message) => getDefaultBaseLogger().warning(message),
|
|
@@ -7913,8 +7881,8 @@ var Logger = {
|
|
|
7913
7881
|
error: (message) => getDefaultBaseLogger().error(message),
|
|
7914
7882
|
debug: (message) => getDefaultBaseLogger().debug(message),
|
|
7915
7883
|
start: (message) => getDefaultBaseLogger().start(message),
|
|
7916
|
-
useTemplate: (
|
|
7917
|
-
if (
|
|
7884
|
+
useTemplate: (logger17) => {
|
|
7885
|
+
if (logger17) return createTemplateLogger(createBaseLogger("", logger17));
|
|
7918
7886
|
return createTemplateLogger();
|
|
7919
7887
|
}
|
|
7920
7888
|
};
|
|
@@ -7988,7 +7956,7 @@ var LOCATION_NETWORK_SUFFIX_PATTERNS = [
|
|
|
7988
7956
|
];
|
|
7989
7957
|
var cachedStripLogoSrcPromise = null;
|
|
7990
7958
|
var cachedEnrichmentByContext = /* @__PURE__ */ new WeakMap();
|
|
7991
|
-
var
|
|
7959
|
+
var logger14 = createInternalLogger("Watermarkify");
|
|
7992
7960
|
var normalizeText = (value) => String(value || "").trim();
|
|
7993
7961
|
var toInline = (value, maxLen = 200) => {
|
|
7994
7962
|
const text = normalizeText(value);
|
|
@@ -8230,9 +8198,9 @@ var resolveWithCustomResolver = async (page, baseMeta, options = {}) => {
|
|
|
8230
8198
|
location: toInline(resolved.location, 80)
|
|
8231
8199
|
};
|
|
8232
8200
|
if (enrichment.ip || enrichment.location) {
|
|
8233
|
-
|
|
8201
|
+
logger14.info(`\u81EA\u5B9A\u4E49 resolver \u547D\u4E2D: ip=${enrichment.ip || "-"}, loc=${enrichment.location || "-"}`);
|
|
8234
8202
|
} else {
|
|
8235
|
-
|
|
8203
|
+
logger14.warning("\u81EA\u5B9A\u4E49 resolver \u5DF2\u6267\u884C\uFF0C\u4F46\u672A\u8FD4\u56DE IP/Loc");
|
|
8236
8204
|
}
|
|
8237
8205
|
return enrichment;
|
|
8238
8206
|
} finally {
|
|
@@ -8421,12 +8389,12 @@ var normalizeWatermarkifyRenderMode = (value) => {
|
|
|
8421
8389
|
};
|
|
8422
8390
|
var composeScreenshotBufferWithBrowser = async (page, buffer, overlaySvg, imageInfo = {}, options = {}) => {
|
|
8423
8391
|
if (!page || typeof page.context !== "function") {
|
|
8424
|
-
|
|
8392
|
+
logger14.warning("watermarkify \u6D4F\u89C8\u5668\u5408\u6210\u8DF3\u8FC7: \u7F3A\u5C11\u53EF\u7528 page");
|
|
8425
8393
|
return buffer;
|
|
8426
8394
|
}
|
|
8427
8395
|
const renderScope = await openProbePage(page);
|
|
8428
8396
|
if (!renderScope?.page) {
|
|
8429
|
-
|
|
8397
|
+
logger14.warning("watermarkify \u6D4F\u89C8\u5668\u5408\u6210\u8DF3\u8FC7: \u65E0\u6CD5\u521B\u5EFA render page");
|
|
8430
8398
|
return buffer;
|
|
8431
8399
|
}
|
|
8432
8400
|
try {
|
|
@@ -8491,13 +8459,13 @@ var composeScreenshotBufferWithBrowser = async (page, buffer, overlaySvg, imageI
|
|
|
8491
8459
|
fullPage: true,
|
|
8492
8460
|
animations: "disabled"
|
|
8493
8461
|
}).catch((error) => {
|
|
8494
|
-
|
|
8462
|
+
logger14.warning(`watermarkify \u6D4F\u89C8\u5668\u5408\u6210\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
8495
8463
|
return null;
|
|
8496
8464
|
});
|
|
8497
8465
|
if (Buffer.isBuffer(composed) && composed.length > 0) {
|
|
8498
8466
|
return composed;
|
|
8499
8467
|
}
|
|
8500
|
-
|
|
8468
|
+
logger14.warning("watermarkify \u6D4F\u89C8\u5668\u5408\u6210\u5931\u8D25: \u672A\u5F97\u5230\u6709\u6548\u622A\u56FE\u7ED3\u679C");
|
|
8501
8469
|
return buffer;
|
|
8502
8470
|
} finally {
|
|
8503
8471
|
await renderScope.close().catch(() => {
|
|
@@ -8510,7 +8478,7 @@ var resolveWithIpLookup = async (page, options = {}) => {
|
|
|
8510
8478
|
}
|
|
8511
8479
|
const probeScope = await openProbePage(page);
|
|
8512
8480
|
if (!probeScope?.page) {
|
|
8513
|
-
|
|
8481
|
+
logger14.warning("ipLookup \u8DF3\u8FC7: \u65E0\u6CD5\u521B\u5EFA probe page");
|
|
8514
8482
|
return null;
|
|
8515
8483
|
}
|
|
8516
8484
|
const timeoutMs = Math.max(
|
|
@@ -8519,12 +8487,12 @@ var resolveWithIpLookup = async (page, options = {}) => {
|
|
|
8519
8487
|
);
|
|
8520
8488
|
try {
|
|
8521
8489
|
const probePage = probeScope.page;
|
|
8522
|
-
|
|
8490
|
+
logger14.info(`ipLookup \u5C1D\u8BD5: url=${DEFAULT_IP_LOOKUP_URL}, timeoutMs=${timeoutMs}`);
|
|
8523
8491
|
const response = await probePage.goto(DEFAULT_IP_LOOKUP_URL, {
|
|
8524
8492
|
waitUntil: "commit",
|
|
8525
8493
|
timeout: timeoutMs
|
|
8526
8494
|
}).catch((error) => {
|
|
8527
|
-
|
|
8495
|
+
logger14.warning(`ipLookup \u8BF7\u6C42\u5931\u8D25: url=${DEFAULT_IP_LOOKUP_URL}, error=${error instanceof Error ? error.message : String(error)}`);
|
|
8528
8496
|
return null;
|
|
8529
8497
|
});
|
|
8530
8498
|
const status = response && typeof response.status === "function" ? response.status() : 0;
|
|
@@ -8546,13 +8514,13 @@ var resolveWithIpLookup = async (page, options = {}) => {
|
|
|
8546
8514
|
}
|
|
8547
8515
|
const parsed = parseIpIpJsonResponse(rawText);
|
|
8548
8516
|
if (parsed?.ip || parsed?.location) {
|
|
8549
|
-
|
|
8517
|
+
logger14.info(`ipLookup \u6210\u529F: url=${DEFAULT_IP_LOOKUP_URL}, status=${status || "-"}, contentType=${contentType || "-"}, ip=${parsed.ip || "-"}, loc=${parsed.location || "-"}`);
|
|
8550
8518
|
return parsed;
|
|
8551
8519
|
}
|
|
8552
|
-
|
|
8520
|
+
logger14.warning(`ipLookup \u672A\u89E3\u6790\u51FA IP/Loc: url=${DEFAULT_IP_LOOKUP_URL}, status=${status || "-"}, contentType=${contentType || "-"}, preview=${shortenTail(rawText, 120) || "[empty]"}`);
|
|
8553
8521
|
return null;
|
|
8554
8522
|
} catch (error) {
|
|
8555
|
-
|
|
8523
|
+
logger14.warning(`ipLookup \u6267\u884C\u5F02\u5E38\uFF0C\u672A\u83B7\u5F97 IP/Loc: ${error instanceof Error ? error.message : String(error)}`);
|
|
8556
8524
|
return null;
|
|
8557
8525
|
} finally {
|
|
8558
8526
|
await probeScope.close().catch(() => {
|
|
@@ -8566,10 +8534,10 @@ var resolveEnrichment = async (page, baseMeta, options) => {
|
|
|
8566
8534
|
ip: toInline(options.ip, 80),
|
|
8567
8535
|
location: toInline(options.location, 80)
|
|
8568
8536
|
};
|
|
8569
|
-
|
|
8537
|
+
logger14.info(`enrichment \u5F00\u59CB: host=${baseMeta.hostname || "-"}, hasPresetIp=${Boolean(merged.ip)}, hasPresetLoc=${Boolean(merged.location)}, ipLookup=${options.ipLookup !== false}`);
|
|
8570
8538
|
if (!merged.ip || !merged.location) {
|
|
8571
8539
|
if (cached?.ip || cached?.location) {
|
|
8572
|
-
|
|
8540
|
+
logger14.info(`enrichment \u547D\u4E2D\u4E0A\u4E0B\u6587\u7F13\u5B58: ip=${cached.ip || "-"}, loc=${cached.location || "-"}`);
|
|
8573
8541
|
}
|
|
8574
8542
|
fillEnrichment(merged, cached);
|
|
8575
8543
|
}
|
|
@@ -8593,15 +8561,15 @@ var resolveEnrichment = async (page, baseMeta, options) => {
|
|
|
8593
8561
|
"x-geo-country"
|
|
8594
8562
|
]), 80);
|
|
8595
8563
|
if (!merged.location || isWeakLocationValue(merged.location) && headerLocation) {
|
|
8596
|
-
|
|
8564
|
+
logger14.info(`enrichment \u4F7F\u7528\u54CD\u5E94\u5934\u8865\u5145 Loc: ${headerLocation || "-"}`);
|
|
8597
8565
|
merged.location = headerLocation || merged.location;
|
|
8598
8566
|
}
|
|
8599
8567
|
}
|
|
8600
8568
|
writeCachedEnrichment(page, merged);
|
|
8601
8569
|
if (merged.ip || merged.location) {
|
|
8602
|
-
|
|
8570
|
+
logger14.info(`enrichment \u5B8C\u6210: ip=${merged.ip || "-"}, loc=${merged.location || "-"}`);
|
|
8603
8571
|
} else {
|
|
8604
|
-
|
|
8572
|
+
logger14.warning("enrichment \u5B8C\u6210: \u672A\u83B7\u5F97 IP/Loc");
|
|
8605
8573
|
}
|
|
8606
8574
|
return merged;
|
|
8607
8575
|
};
|
|
@@ -9414,7 +9382,7 @@ var watermarkifyScreenshotBuffer = async (buffer, meta, page = null, options = {
|
|
|
9414
9382
|
}
|
|
9415
9383
|
const imageInfo = readImageInfo(buffer);
|
|
9416
9384
|
if (!imageInfo.width || !imageInfo.height || !imageInfo.mimeType) {
|
|
9417
|
-
|
|
9385
|
+
logger14.warning("watermarkify \u8DF3\u8FC7: \u65E0\u6CD5\u89E3\u6790\u622A\u56FE\u5C3A\u5BF8\u6216\u683C\u5F0F");
|
|
9418
9386
|
return buffer;
|
|
9419
9387
|
}
|
|
9420
9388
|
const isMobileStrip = normalizeDevice(meta.device) === Device.Mobile && hasStrip;
|
|
@@ -9432,7 +9400,7 @@ var watermarkifyScreenshotBuffer = async (buffer, meta, page = null, options = {
|
|
|
9432
9400
|
|
|
9433
9401
|
// src/internals/compression.js
|
|
9434
9402
|
import { Jimp, JimpMime, ResizeStrategy } from "jimp";
|
|
9435
|
-
var
|
|
9403
|
+
var logger15 = createInternalLogger("Compression");
|
|
9436
9404
|
var DEFAULT_SCREENSHOT_MAX_BYTES = 5 * 1024 * 1024;
|
|
9437
9405
|
var DEFAULT_SCREENSHOT_OUTPUT_TYPE = "jpeg";
|
|
9438
9406
|
var DEFAULT_SCREENSHOT_QUALITY = 0.72;
|
|
@@ -9551,18 +9519,18 @@ var compressImageBufferToBase64 = async (buffer, compression) => {
|
|
|
9551
9519
|
return buffer.toString("base64");
|
|
9552
9520
|
}
|
|
9553
9521
|
const result = await compressImageBuffer(buffer, compression).catch((error) => {
|
|
9554
|
-
|
|
9522
|
+
logger15.warning(`captureScreen \u538B\u7F29\u5931\u8D25\uFF0C\u8FD4\u56DE\u539F\u56FE: ${error instanceof Error ? error.message : String(error)}`);
|
|
9555
9523
|
return null;
|
|
9556
9524
|
});
|
|
9557
9525
|
if (!result?.buffer) {
|
|
9558
9526
|
return buffer.toString("base64");
|
|
9559
9527
|
}
|
|
9560
9528
|
if (result.withinLimit) {
|
|
9561
|
-
|
|
9529
|
+
logger15.info(
|
|
9562
9530
|
`captureScreen \u5DF2\u538B\u7F29: ${originalBytes} -> ${result.bytes} bytes, format=${result.format}, quality=${result.quality}, scale=${result.scale}, size=${result.width}x${result.height}`
|
|
9563
9531
|
);
|
|
9564
9532
|
} else {
|
|
9565
|
-
|
|
9533
|
+
logger15.warning(
|
|
9566
9534
|
`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}`
|
|
9567
9535
|
);
|
|
9568
9536
|
}
|
|
@@ -9570,7 +9538,7 @@ var compressImageBufferToBase64 = async (buffer, compression) => {
|
|
|
9570
9538
|
};
|
|
9571
9539
|
|
|
9572
9540
|
// src/share.js
|
|
9573
|
-
var
|
|
9541
|
+
var logger16 = createInternalLogger("Share");
|
|
9574
9542
|
var DEFAULT_TIMEOUT_MS2 = 50 * 1e3;
|
|
9575
9543
|
var DEFAULT_PAYLOAD_SNAPSHOT_MAX_LEN = 500;
|
|
9576
9544
|
var DEFAULT_POLL_INTERVAL_MS = 120;
|
|
@@ -9707,7 +9675,7 @@ var createDomShareMonitor = async (page, options = {}) => {
|
|
|
9707
9675
|
const onMatch = typeof options.onMatch === "function" ? options.onMatch : null;
|
|
9708
9676
|
const onTelemetry = typeof options.onTelemetry === "function" ? options.onTelemetry : null;
|
|
9709
9677
|
let matched = false;
|
|
9710
|
-
|
|
9678
|
+
logger16.info(`DOM \u76D1\u542C\u51C6\u5907\u6302\u8F7D: selectors=${toJsonInline(selectors, 120)}, mode=${mode}`);
|
|
9711
9679
|
const monitor = await Mutation.useMonitor(page, selectors, {
|
|
9712
9680
|
mode,
|
|
9713
9681
|
onMutation: (context = {}) => {
|
|
@@ -9725,12 +9693,12 @@ ${text}`;
|
|
|
9725
9693
|
});
|
|
9726
9694
|
}
|
|
9727
9695
|
if (mutationCount <= 5 || mutationCount % 50 === 0) {
|
|
9728
|
-
|
|
9696
|
+
logger16.info(`DOM \u53D8\u5316\u5DF2\u6355\u83B7: mutationCount=${mutationCount}, mutationNodes=${mutationNodes.length}`);
|
|
9729
9697
|
}
|
|
9730
9698
|
const [candidate] = Utils.parseLinks(rawDom, { prefix }) || [];
|
|
9731
9699
|
if (!candidate) return;
|
|
9732
9700
|
matched = true;
|
|
9733
|
-
|
|
9701
|
+
logger16.success("captureLink.domHit", `DOM \u547D\u4E2D\u5206\u4EAB\u94FE\u63A5: mutationCount=${mutationCount}, link=${candidate}`);
|
|
9734
9702
|
if (onMatch) {
|
|
9735
9703
|
onMatch({
|
|
9736
9704
|
link: candidate,
|
|
@@ -9746,7 +9714,7 @@ ${text}`;
|
|
|
9746
9714
|
return {
|
|
9747
9715
|
stop: async () => {
|
|
9748
9716
|
const result = await monitor.stop();
|
|
9749
|
-
|
|
9717
|
+
logger16.info(`DOM \u76D1\u542C\u5DF2\u505C\u6B62: totalMutations=${result?.totalMutations || 0}`);
|
|
9750
9718
|
return result;
|
|
9751
9719
|
}
|
|
9752
9720
|
};
|
|
@@ -9795,8 +9763,8 @@ var Share = {
|
|
|
9795
9763
|
if (share.mode === "response" && apiMatchers.length === 0) {
|
|
9796
9764
|
throw new Error("Share.captureLink requires share.xurl[0] api matcher when mode=response");
|
|
9797
9765
|
}
|
|
9798
|
-
|
|
9799
|
-
|
|
9766
|
+
logger16.start("captureLink", `mode=${share.mode}, timeoutMs=${timeoutDisabled ? "disabled" : timeoutMs}, prefix=${share.prefix}`);
|
|
9767
|
+
logger16.info(`captureLink \u914D\u7F6E: xurl=${toJsonInline(share.xurl)}, domMode=${domMode}, domSelectors=${toJsonInline(domSelectors, 120)}`);
|
|
9800
9768
|
const stats = {
|
|
9801
9769
|
actionTimedOut: false,
|
|
9802
9770
|
domMutationCount: 0,
|
|
@@ -9808,7 +9776,7 @@ var Share = {
|
|
|
9808
9776
|
responseSampleUrls: []
|
|
9809
9777
|
};
|
|
9810
9778
|
if (isAborted()) {
|
|
9811
|
-
|
|
9779
|
+
logger16.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
|
|
9812
9780
|
return {
|
|
9813
9781
|
link: null,
|
|
9814
9782
|
payloadText: "",
|
|
@@ -9831,7 +9799,7 @@ var Share = {
|
|
|
9831
9799
|
link: validated,
|
|
9832
9800
|
payloadText: String(payloadText || "")
|
|
9833
9801
|
};
|
|
9834
|
-
|
|
9802
|
+
logger16.info(`\u5019\u9009\u94FE\u63A5\u5DF2\u786E\u8BA4: source=${source}, link=${validated}`);
|
|
9835
9803
|
return true;
|
|
9836
9804
|
};
|
|
9837
9805
|
const resolveResponseCandidate = (responseText) => {
|
|
@@ -9866,7 +9834,7 @@ var Share = {
|
|
|
9866
9834
|
try {
|
|
9867
9835
|
await monitor.stop();
|
|
9868
9836
|
} catch (error) {
|
|
9869
|
-
|
|
9837
|
+
logger16.warning(`\u505C\u6B62 DOM \u76D1\u542C\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`);
|
|
9870
9838
|
}
|
|
9871
9839
|
};
|
|
9872
9840
|
const onResponse = async (response) => {
|
|
@@ -9880,29 +9848,29 @@ var Share = {
|
|
|
9880
9848
|
stats.responseSampleUrls.push(url);
|
|
9881
9849
|
}
|
|
9882
9850
|
if (stats.responseObserved <= 5) {
|
|
9883
|
-
|
|
9851
|
+
logger16.info(`\u63A5\u53E3\u54CD\u5E94\u91C7\u6837(${stats.responseObserved}): ${url}`);
|
|
9884
9852
|
}
|
|
9885
9853
|
if (!apiMatchers.some((matcher) => url.includes(matcher))) return;
|
|
9886
9854
|
stats.responseMatched += 1;
|
|
9887
9855
|
stats.lastMatchedUrl = url;
|
|
9888
|
-
|
|
9856
|
+
logger16.info(`\u63A5\u53E3\u547D\u4E2D\u5339\u914D(${stats.responseMatched}): ${url}`);
|
|
9889
9857
|
const text = await response.text();
|
|
9890
9858
|
const hit = resolveResponseCandidate(text);
|
|
9891
9859
|
if (!hit?.link) {
|
|
9892
9860
|
if (stats.responseMatched <= 3) {
|
|
9893
|
-
|
|
9861
|
+
logger16.info(`\u63A5\u53E3\u89E3\u6790\u5B8C\u6210\u4F46\u672A\u63D0\u53D6\u5230\u5206\u4EAB\u94FE\u63A5: payloadSize=${text.length}`);
|
|
9894
9862
|
}
|
|
9895
9863
|
return;
|
|
9896
9864
|
}
|
|
9897
9865
|
stats.responseResolved += 1;
|
|
9898
|
-
|
|
9866
|
+
logger16.success("captureLink.responseHit", `\u63A5\u53E3\u547D\u4E2D\u5206\u4EAB\u94FE\u63A5: url=${url}, link=${hit.link}`);
|
|
9899
9867
|
setCandidate("response", hit.link, hit.payloadText);
|
|
9900
9868
|
} catch (error) {
|
|
9901
|
-
|
|
9869
|
+
logger16.warning(`\u63A5\u53E3\u54CD\u5E94\u5904\u7406\u5F02\u5E38: ${error instanceof Error ? error.message : String(error)}`);
|
|
9902
9870
|
}
|
|
9903
9871
|
};
|
|
9904
9872
|
if (share.mode === "dom") {
|
|
9905
|
-
|
|
9873
|
+
logger16.info("\u5F53\u524D\u4E3A DOM \u6A21\u5F0F\uFF0C\u4EC5\u542F\u7528 DOM \u76D1\u542C");
|
|
9906
9874
|
domMonitor = await createDomShareMonitor(page, {
|
|
9907
9875
|
prefix: share.prefix,
|
|
9908
9876
|
selectors: domSelectors,
|
|
@@ -9917,17 +9885,17 @@ var Share = {
|
|
|
9917
9885
|
});
|
|
9918
9886
|
}
|
|
9919
9887
|
if (share.mode === "response") {
|
|
9920
|
-
|
|
9888
|
+
logger16.info(`\u5F53\u524D\u4E3A\u63A5\u53E3\u6A21\u5F0F\uFF0C\u6302\u8F7D response \u76D1\u542C: apiMatchers=${toJsonInline(apiMatchers, 160)}`);
|
|
9921
9889
|
page.on("response", onResponse);
|
|
9922
9890
|
}
|
|
9923
9891
|
if (share.mode === "custom") {
|
|
9924
|
-
|
|
9892
|
+
logger16.info("\u5F53\u524D\u4E3A custom \u6A21\u5F0F\uFF0C\u5C06\u4F7F\u7528 performActions \u8FD4\u56DE\u503C");
|
|
9925
9893
|
}
|
|
9926
9894
|
const deadline = timeoutDisabled ? Infinity : Date.now() + timeoutMs;
|
|
9927
9895
|
const getRemainingMs = () => timeoutDisabled ? Infinity : Math.max(0, deadline - Date.now());
|
|
9928
9896
|
try {
|
|
9929
9897
|
const actionTimeout = getRemainingMs();
|
|
9930
|
-
|
|
9898
|
+
logger16.start("captureLink.performActions", `\u6267\u884C\u52A8\u4F5C\u9884\u7B97=${timeoutDisabled ? "disabled" : `${actionTimeout}ms`}`);
|
|
9931
9899
|
let actionValue;
|
|
9932
9900
|
if (!isAborted() && actionTimeout > 0) {
|
|
9933
9901
|
let timer = null;
|
|
@@ -9940,30 +9908,30 @@ var Share = {
|
|
|
9940
9908
|
]);
|
|
9941
9909
|
if (timer) clearTimeout(timer);
|
|
9942
9910
|
if (actionResult.type === "error") {
|
|
9943
|
-
|
|
9911
|
+
logger16.fail("captureLink.performActions", actionResult.error);
|
|
9944
9912
|
throw actionResult.error;
|
|
9945
9913
|
}
|
|
9946
9914
|
if (actionResult.type === "timeout") {
|
|
9947
9915
|
stats.actionTimedOut = true;
|
|
9948
|
-
|
|
9916
|
+
logger16.warning(`performActions \u5DF2\u8D85\u65F6 (${actionTimeout}ms)\uFF0C\u52A8\u4F5C\u53EF\u80FD\u4ECD\u5728\u5F02\u6B65\u6267\u884C`);
|
|
9949
9917
|
} else {
|
|
9950
9918
|
actionValue = actionResult.result;
|
|
9951
|
-
|
|
9919
|
+
logger16.success("captureLink.performActions", "\u6267\u884C\u52A8\u4F5C\u5B8C\u6210");
|
|
9952
9920
|
}
|
|
9953
9921
|
}
|
|
9954
9922
|
if (share.mode === "custom") {
|
|
9955
9923
|
const customLink = typeof actionValue === "string" ? actionValue : actionValue?.link || actionValue?.payloadText;
|
|
9956
9924
|
const customPayloadText = typeof actionValue === "string" ? actionValue : actionValue?.payloadText;
|
|
9957
9925
|
if (setCandidate("custom", customLink, customPayloadText)) {
|
|
9958
|
-
|
|
9926
|
+
logger16.success("captureLink.customResult", `custom \u547D\u4E2D\u5206\u4EAB\u94FE\u63A5: link=${candidates.custom.link}`);
|
|
9959
9927
|
} else {
|
|
9960
|
-
|
|
9928
|
+
logger16.warning("performActions \u6267\u884C\u5B8C\u6210\u4F46\u672A\u8FD4\u56DE\u6709\u6548\u5206\u4EAB\u94FE\u63A5");
|
|
9961
9929
|
}
|
|
9962
9930
|
}
|
|
9963
9931
|
let nextProgressLogTs = Date.now() + 3e3;
|
|
9964
9932
|
while (true) {
|
|
9965
9933
|
if (isAborted()) {
|
|
9966
|
-
|
|
9934
|
+
logger16.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
|
|
9967
9935
|
return {
|
|
9968
9936
|
link: null,
|
|
9969
9937
|
payloadText: "",
|
|
@@ -9973,7 +9941,7 @@ var Share = {
|
|
|
9973
9941
|
}
|
|
9974
9942
|
const selected = candidates[share.mode];
|
|
9975
9943
|
if (selected?.link) {
|
|
9976
|
-
|
|
9944
|
+
logger16.success("captureLink", `\u6355\u83B7\u6210\u529F: source=${share.mode}, link=${selected.link}`);
|
|
9977
9945
|
return {
|
|
9978
9946
|
link: selected.link,
|
|
9979
9947
|
payloadText: selected.payloadText,
|
|
@@ -9986,7 +9954,7 @@ var Share = {
|
|
|
9986
9954
|
if (remaining <= 0) break;
|
|
9987
9955
|
const now = Date.now();
|
|
9988
9956
|
if (now >= nextProgressLogTs) {
|
|
9989
|
-
|
|
9957
|
+
logger16.info(
|
|
9990
9958
|
`captureLink \u7B49\u5F85\u4E2D: remaining=${timeoutDisabled ? "disabled" : `${remaining}ms`}, domMutationCount=${stats.domMutationCount}, responseMatched=${stats.responseMatched}`
|
|
9991
9959
|
);
|
|
9992
9960
|
nextProgressLogTs = now + 5e3;
|
|
@@ -9994,11 +9962,11 @@ var Share = {
|
|
|
9994
9962
|
await delay5(Math.max(0, Math.min(DEFAULT_POLL_INTERVAL_MS, remaining)));
|
|
9995
9963
|
}
|
|
9996
9964
|
if (!timeoutDisabled && share.mode === "response" && stats.responseMatched === 0) {
|
|
9997
|
-
|
|
9965
|
+
logger16.warning(
|
|
9998
9966
|
`\u63A5\u53E3\u76D1\u542C\u672A\u547D\u4E2D: apiMatchers=${toJsonInline(apiMatchers, 220)}, \u54CD\u5E94\u6837\u672CURLs=${toJsonInline(stats.responseSampleUrls, 420)}`
|
|
9999
9967
|
);
|
|
10000
9968
|
}
|
|
10001
|
-
|
|
9969
|
+
logger16.warning(
|
|
10002
9970
|
`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"}`
|
|
10003
9971
|
);
|
|
10004
9972
|
return {
|
|
@@ -10010,7 +9978,7 @@ var Share = {
|
|
|
10010
9978
|
} finally {
|
|
10011
9979
|
if (share.mode === "response") {
|
|
10012
9980
|
page.off("response", onResponse);
|
|
10013
|
-
|
|
9981
|
+
logger16.info("response \u76D1\u542C\u5DF2\u5378\u8F7D");
|
|
10014
9982
|
}
|
|
10015
9983
|
await stopDomMonitor();
|
|
10016
9984
|
}
|