@skrillex1224/playwright-toolkit 2.1.147 → 2.1.150
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 +25 -0
- package/dist/browser.js.map +2 -2
- package/dist/index.cjs +48 -13
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +48 -13
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -122,6 +122,31 @@ var createActorInfo = (info) => {
|
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
var ActorInfo = {
|
|
125
|
+
qbot: createActorInfo({
|
|
126
|
+
key: "qbot",
|
|
127
|
+
name: "\u641C\u72D7QBot",
|
|
128
|
+
domain: "m.sogou.com",
|
|
129
|
+
path: "/web/searchList.jsp",
|
|
130
|
+
share: {
|
|
131
|
+
mode: "dom",
|
|
132
|
+
prefix: "",
|
|
133
|
+
xurl: []
|
|
134
|
+
}
|
|
135
|
+
}),
|
|
136
|
+
douyin: createActorInfo({
|
|
137
|
+
key: "douyin",
|
|
138
|
+
name: "\u6296\u97F3\u641C\u7D22",
|
|
139
|
+
domain: "www.douyin.com",
|
|
140
|
+
path: "/search",
|
|
141
|
+
share: {
|
|
142
|
+
mode: "response",
|
|
143
|
+
prefix: "",
|
|
144
|
+
xurl: [
|
|
145
|
+
"/aweme/v1/web/web_shorten",
|
|
146
|
+
"data"
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
125
150
|
doubao: createActorInfo({
|
|
126
151
|
key: "doubao",
|
|
127
152
|
name: "\u8C46\u5305",
|
|
@@ -1250,6 +1275,14 @@ var normalizeByPassDomains = (domains) => {
|
|
|
1250
1275
|
if (!Array.isArray(domains)) return [];
|
|
1251
1276
|
return domains.map((item) => String(item || "").trim()).filter(Boolean);
|
|
1252
1277
|
};
|
|
1278
|
+
var compileByPassMatcher = (patternRaw) => {
|
|
1279
|
+
const pattern = String(patternRaw || "").trim().toLowerCase();
|
|
1280
|
+
if (!pattern) return null;
|
|
1281
|
+
if (!pattern.includes("*")) return { pattern, test: (hostname) => hostname === pattern };
|
|
1282
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
1283
|
+
const regex = new RegExp(`^${escaped}$`);
|
|
1284
|
+
return { pattern, test: (hostname) => regex.test(hostname) };
|
|
1285
|
+
};
|
|
1253
1286
|
var resolveProxyLaunchOptions = (proxyConfiguration = {}) => {
|
|
1254
1287
|
const config = proxyConfiguration && typeof proxyConfiguration === "object" && !Array.isArray(proxyConfiguration) ? proxyConfiguration : {};
|
|
1255
1288
|
const proxyUrl = String(config.proxy_url || "").trim();
|
|
@@ -1312,7 +1345,7 @@ var Launch = {
|
|
|
1312
1345
|
return () => {
|
|
1313
1346
|
};
|
|
1314
1347
|
}
|
|
1315
|
-
const
|
|
1348
|
+
const matchers = byPassDomains.map((pattern) => compileByPassMatcher(pattern)).filter(Boolean);
|
|
1316
1349
|
const requestHandler = (req) => {
|
|
1317
1350
|
const requestUrl = req.url();
|
|
1318
1351
|
let hostname = "";
|
|
@@ -1321,8 +1354,9 @@ var Launch = {
|
|
|
1321
1354
|
} catch {
|
|
1322
1355
|
return;
|
|
1323
1356
|
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1357
|
+
const matched = matchers.find((item) => item.test(hostname));
|
|
1358
|
+
if (!matched) return;
|
|
1359
|
+
logger6.info(`[\u76F4\u8FDE\u547D\u4E2D] \u89C4\u5219=${matched.pattern} \u57DF\u540D=${hostname} \u8D44\u6E90\u7C7B\u578B=${req.resourceType()} \u65B9\u6CD5=${req.method()} \u5730\u5740=${requestUrl}`);
|
|
1326
1360
|
};
|
|
1327
1361
|
page.on("request", requestHandler);
|
|
1328
1362
|
return () => page.off("request", requestHandler);
|
|
@@ -1411,13 +1445,18 @@ function useCaptchaMonitor(page, options) {
|
|
|
1411
1445
|
if (!onDetected || typeof onDetected !== "function") {
|
|
1412
1446
|
throw new Error("[CaptchaMonitor] onDetected \u5FC5\u987B\u662F\u4E00\u4E2A\u51FD\u6570");
|
|
1413
1447
|
}
|
|
1414
|
-
let
|
|
1448
|
+
let isStopped = false;
|
|
1449
|
+
let isHandling = false;
|
|
1415
1450
|
let frameHandler = null;
|
|
1416
1451
|
let exposedFunctionName = null;
|
|
1417
1452
|
const triggerDetected = async () => {
|
|
1418
|
-
if (
|
|
1419
|
-
|
|
1420
|
-
|
|
1453
|
+
if (isStopped || isHandling) return;
|
|
1454
|
+
isHandling = true;
|
|
1455
|
+
try {
|
|
1456
|
+
await onDetected();
|
|
1457
|
+
} finally {
|
|
1458
|
+
isHandling = false;
|
|
1459
|
+
}
|
|
1421
1460
|
};
|
|
1422
1461
|
const cleanupFns = [];
|
|
1423
1462
|
if (domSelector) {
|
|
@@ -1431,10 +1470,6 @@ function useCaptchaMonitor(page, options) {
|
|
|
1431
1470
|
const checkAndReport = () => {
|
|
1432
1471
|
const element = document.querySelector(selector);
|
|
1433
1472
|
if (element) {
|
|
1434
|
-
if (observer) {
|
|
1435
|
-
observer.disconnect();
|
|
1436
|
-
observer = null;
|
|
1437
|
-
}
|
|
1438
1473
|
if (window[callbackName]) {
|
|
1439
1474
|
window[callbackName]();
|
|
1440
1475
|
}
|
|
@@ -1442,7 +1477,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
1442
1477
|
}
|
|
1443
1478
|
return false;
|
|
1444
1479
|
};
|
|
1445
|
-
|
|
1480
|
+
checkAndReport();
|
|
1446
1481
|
observer = new MutationObserver((mutations) => {
|
|
1447
1482
|
let shouldCheck = false;
|
|
1448
1483
|
for (const mutation of mutations) {
|
|
@@ -1508,7 +1543,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
1508
1543
|
for (const fn of cleanupFns) {
|
|
1509
1544
|
await fn();
|
|
1510
1545
|
}
|
|
1511
|
-
|
|
1546
|
+
isStopped = true;
|
|
1512
1547
|
}
|
|
1513
1548
|
};
|
|
1514
1549
|
}
|