@skrillex1224/playwright-toolkit 2.1.218 → 2.1.220
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/browser.js.map +1 -1
- package/dist/index.cjs +39 -7
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +39 -7
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -439,9 +439,13 @@ function createInternalLogger(moduleName, explicitLogger) {
|
|
|
439
439
|
},
|
|
440
440
|
warning(message) {
|
|
441
441
|
baseLogger.warning(message);
|
|
442
|
+
a;
|
|
442
443
|
},
|
|
443
444
|
info(message) {
|
|
444
445
|
baseLogger.info(message);
|
|
446
|
+
},
|
|
447
|
+
error(message) {
|
|
448
|
+
baseLogger.error(message);
|
|
445
449
|
}
|
|
446
450
|
};
|
|
447
451
|
}
|
|
@@ -682,9 +686,9 @@ var resolveResourceTypeMeta = (domain) => {
|
|
|
682
686
|
if (!byType || byType.size === 0) {
|
|
683
687
|
return { resourceType: "", resourceTypeCounts: void 0 };
|
|
684
688
|
}
|
|
685
|
-
const entries = Array.from(byType.entries()).filter(([type, count]) => type && Number(count) > 0).sort((
|
|
686
|
-
if (Number(b[1]) !== Number(
|
|
687
|
-
return String(
|
|
689
|
+
const entries = Array.from(byType.entries()).filter(([type, count]) => type && Number(count) > 0).sort((a2, b) => {
|
|
690
|
+
if (Number(b[1]) !== Number(a2[1])) return Number(b[1]) - Number(a2[1]);
|
|
691
|
+
return String(a2[0]).localeCompare(String(b[0]));
|
|
688
692
|
});
|
|
689
693
|
if (entries.length === 0) {
|
|
690
694
|
return { resourceType: "", resourceTypeCounts: void 0 };
|
|
@@ -774,10 +778,10 @@ var normalizeDomainRows = (hosts) => {
|
|
|
774
778
|
resourceTypeCounts: resourceTypeMeta.resourceTypeCounts || void 0
|
|
775
779
|
});
|
|
776
780
|
}
|
|
777
|
-
rows.sort((
|
|
778
|
-
if (b.totalBytes !==
|
|
779
|
-
if (b.requests !==
|
|
780
|
-
return String(
|
|
781
|
+
rows.sort((a2, b) => {
|
|
782
|
+
if (b.totalBytes !== a2.totalBytes) return b.totalBytes - a2.totalBytes;
|
|
783
|
+
if (b.requests !== a2.requests) return b.requests - a2.requests;
|
|
784
|
+
return String(a2.domain).localeCompare(String(b.domain));
|
|
781
785
|
});
|
|
782
786
|
return {
|
|
783
787
|
topDomains: rows.slice(0, MAX_TOP_DOMAINS),
|
|
@@ -2998,9 +3002,17 @@ var DEFAULT_BYTEDANCE_CAPTCHA_OPTIONS = Object.freeze({
|
|
|
2998
3002
|
actionVisibleTimeoutMs: 1500,
|
|
2999
3003
|
sourceImageVisibleTimeoutMs: 3e3,
|
|
3000
3004
|
challengeReadyTimeoutMs: 15e3,
|
|
3005
|
+
challengeReadyRefreshTimeoutMs: 2e4,
|
|
3001
3006
|
challengeReadyPollMs: 300,
|
|
3002
3007
|
loadingIndicatorVisibleTimeoutMs: 200,
|
|
3003
3008
|
loadingTexts: ["\u52A0\u8F7D\u4E2D", "\u52A0\u8F7D\u4E2D..."],
|
|
3009
|
+
errorTexts: [
|
|
3010
|
+
"\u68C0\u6D4B\u5230\u60A8\u7684\u7F51\u7EDC\u73AF\u5883\u8F83\u5DEE",
|
|
3011
|
+
"\u7F51\u7EDC\u73AF\u5883\u8F83\u5DEE",
|
|
3012
|
+
"\u8BF7\u66F4\u6362\u7F51\u7EDC\u6216\u8005\u7A0D\u540E\u518D\u8BD5",
|
|
3013
|
+
"\u8BF7\u66F4\u6362\u7F51\u7EDC\u6216\u7A0D\u540E\u518D\u8BD5",
|
|
3014
|
+
"\u7A0D\u540E\u518D\u8BD5"
|
|
3015
|
+
],
|
|
3004
3016
|
recognitionDelayMs: 2e3,
|
|
3005
3017
|
refreshWaitMs: 3e3,
|
|
3006
3018
|
submitWaitMs: 3e3,
|
|
@@ -3167,6 +3179,7 @@ var isAnyCaptchaTextVisible = async (frame, texts, timeout) => {
|
|
|
3167
3179
|
};
|
|
3168
3180
|
var waitForCaptchaChallengeReady = async (page, frame, options) => {
|
|
3169
3181
|
const deadline = Date.now() + options.challengeReadyTimeoutMs;
|
|
3182
|
+
let refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
|
|
3170
3183
|
let hasSeenLoading = false;
|
|
3171
3184
|
while (Date.now() < deadline) {
|
|
3172
3185
|
const isLoadingVisible = await isAnyCaptchaTextVisible(
|
|
@@ -3174,6 +3187,11 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
|
|
|
3174
3187
|
options.loadingTexts,
|
|
3175
3188
|
options.loadingIndicatorVisibleTimeoutMs
|
|
3176
3189
|
);
|
|
3190
|
+
const hasErrorTextVisible = await isAnyCaptchaTextVisible(
|
|
3191
|
+
frame,
|
|
3192
|
+
options.errorTexts,
|
|
3193
|
+
options.loadingIndicatorVisibleTimeoutMs
|
|
3194
|
+
);
|
|
3177
3195
|
hasSeenLoading = hasSeenLoading || isLoadingVisible;
|
|
3178
3196
|
const sourceImages = frame.locator(options.sourceImageSelector);
|
|
3179
3197
|
const imageCount = await sourceImages.count().catch(() => 0);
|
|
@@ -3182,6 +3200,20 @@ var waitForCaptchaChallengeReady = async (page, frame, options) => {
|
|
|
3182
3200
|
logger9.info(hasSeenLoading ? "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u52A0\u8F7D\u5B8C\u6210\u3002" : "\u9A8C\u8BC1\u7801\u56FE\u7247\u5DF2\u5C31\u7EEA\u3002");
|
|
3183
3201
|
return;
|
|
3184
3202
|
}
|
|
3203
|
+
if (hasErrorTextVisible) {
|
|
3204
|
+
logger9.warn("\u9A8C\u8BC1\u7801\u9762\u677F\u51FA\u73B0\u7F51\u7EDC\u5F02\u5E38\u6587\u6848\uFF0C\u5C1D\u8BD5\u7ACB\u5373\u5237\u65B0\u9898\u76EE\u3002");
|
|
3205
|
+
await refreshCaptcha(page, frame, options);
|
|
3206
|
+
refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
|
|
3207
|
+
hasSeenLoading = false;
|
|
3208
|
+
continue;
|
|
3209
|
+
}
|
|
3210
|
+
if (!hasVisibleSourceImage && Date.now() >= refreshDeadline) {
|
|
3211
|
+
logger9.warn(`\u9A8C\u8BC1\u7801\u56FE\u7247\u8D85\u8FC7 ${options.challengeReadyRefreshTimeoutMs}ms \u4ECD\u672A\u51FA\u73B0\uFF0C\u5C1D\u8BD5\u5237\u65B0\u9898\u76EE\u3002`);
|
|
3212
|
+
await refreshCaptcha(page, frame, options);
|
|
3213
|
+
refreshDeadline = Date.now() + options.challengeReadyRefreshTimeoutMs;
|
|
3214
|
+
hasSeenLoading = false;
|
|
3215
|
+
continue;
|
|
3216
|
+
}
|
|
3185
3217
|
await page.waitForTimeout(options.challengeReadyPollMs);
|
|
3186
3218
|
}
|
|
3187
3219
|
throw new Error("Captcha challenge is still loading and did not become ready in time.");
|