@skrillex1224/playwright-toolkit 2.1.147 → 2.1.149
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 +11 -10
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +11 -10
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1438,13 +1438,18 @@ function useCaptchaMonitor(page, options) {
|
|
|
1438
1438
|
if (!onDetected || typeof onDetected !== "function") {
|
|
1439
1439
|
throw new Error("[CaptchaMonitor] onDetected \u5FC5\u987B\u662F\u4E00\u4E2A\u51FD\u6570");
|
|
1440
1440
|
}
|
|
1441
|
-
let
|
|
1441
|
+
let isStopped = false;
|
|
1442
|
+
let isHandling = false;
|
|
1442
1443
|
let frameHandler = null;
|
|
1443
1444
|
let exposedFunctionName = null;
|
|
1444
1445
|
const triggerDetected = async () => {
|
|
1445
|
-
if (
|
|
1446
|
-
|
|
1447
|
-
|
|
1446
|
+
if (isStopped || isHandling) return;
|
|
1447
|
+
isHandling = true;
|
|
1448
|
+
try {
|
|
1449
|
+
await onDetected();
|
|
1450
|
+
} finally {
|
|
1451
|
+
isHandling = false;
|
|
1452
|
+
}
|
|
1448
1453
|
};
|
|
1449
1454
|
const cleanupFns = [];
|
|
1450
1455
|
if (domSelector) {
|
|
@@ -1458,10 +1463,6 @@ function useCaptchaMonitor(page, options) {
|
|
|
1458
1463
|
const checkAndReport = () => {
|
|
1459
1464
|
const element = document.querySelector(selector);
|
|
1460
1465
|
if (element) {
|
|
1461
|
-
if (observer) {
|
|
1462
|
-
observer.disconnect();
|
|
1463
|
-
observer = null;
|
|
1464
|
-
}
|
|
1465
1466
|
if (window[callbackName]) {
|
|
1466
1467
|
window[callbackName]();
|
|
1467
1468
|
}
|
|
@@ -1469,7 +1470,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
1469
1470
|
}
|
|
1470
1471
|
return false;
|
|
1471
1472
|
};
|
|
1472
|
-
|
|
1473
|
+
checkAndReport();
|
|
1473
1474
|
observer = new MutationObserver((mutations) => {
|
|
1474
1475
|
let shouldCheck = false;
|
|
1475
1476
|
for (const mutation of mutations) {
|
|
@@ -1535,7 +1536,7 @@ function useCaptchaMonitor(page, options) {
|
|
|
1535
1536
|
for (const fn of cleanupFns) {
|
|
1536
1537
|
await fn();
|
|
1537
1538
|
}
|
|
1538
|
-
|
|
1539
|
+
isStopped = true;
|
|
1539
1540
|
}
|
|
1540
1541
|
};
|
|
1541
1542
|
}
|