@skrillex1224/playwright-toolkit 3.0.53 → 3.0.54
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 +17 -5
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +17 -5
- package/dist/index.js.map +2 -2
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6782,6 +6782,8 @@ var DEFAULT_QBOT_PAGE_OPTIONS = Object.freeze({
|
|
|
6782
6782
|
formVisibleTimeoutMs: 1e4,
|
|
6783
6783
|
imageVisibleTimeoutMs: 1e4,
|
|
6784
6784
|
extraVisibleTimeoutMs: 5e3,
|
|
6785
|
+
payloadReadyTimeoutMs: 1e4,
|
|
6786
|
+
payloadPollIntervalMs: 200,
|
|
6785
6787
|
vcSelector: "#vc",
|
|
6786
6788
|
vcValueTimeoutMs: 8e3,
|
|
6787
6789
|
submitLoadTimeoutMs: 3e4,
|
|
@@ -6801,6 +6803,7 @@ var parseQbotCaptchaCoordinates = (value = "") => String(value || "").split("|")
|
|
|
6801
6803
|
const [x, y] = pair.split(",").map(Number);
|
|
6802
6804
|
return Number.isFinite(x) && Number.isFinite(y) ? { x, y } : null;
|
|
6803
6805
|
}).filter(Boolean);
|
|
6806
|
+
var normalizeQbotCaptchaExtraPayload = (extra = []) => Array.isArray(extra) ? extra.join(",") : String(extra || "");
|
|
6804
6807
|
async function solveQbotCaptcha(image, extra = [], token, options = {}, dependencies = {}) {
|
|
6805
6808
|
const { callCaptchaRecognitionApi: callCaptchaRecognitionApi2 } = dependencies;
|
|
6806
6809
|
if (!token) {
|
|
@@ -6814,20 +6817,29 @@ async function solveQbotCaptcha(image, extra = [], token, options = {}, dependen
|
|
|
6814
6817
|
token,
|
|
6815
6818
|
type: QBOT_CAPTCHA_TYPE,
|
|
6816
6819
|
image,
|
|
6817
|
-
extra
|
|
6820
|
+
extra: normalizeQbotCaptchaExtraPayload(extra)
|
|
6818
6821
|
});
|
|
6819
6822
|
return response?.data?.data ?? response?.data;
|
|
6820
6823
|
}
|
|
6821
6824
|
var readQbotCaptcha = async (page, config) => {
|
|
6822
6825
|
const imageLocator = page.locator(config.imageSelector).first();
|
|
6823
6826
|
await imageLocator.waitFor({ state: "visible", timeout: config.imageVisibleTimeoutMs });
|
|
6824
|
-
const
|
|
6827
|
+
const extraLocator = page.locator(config.extraSelector).first();
|
|
6828
|
+
await extraLocator.waitFor({ state: "visible", timeout: config.extraVisibleTimeoutMs });
|
|
6829
|
+
const deadline = Date.now() + config.payloadReadyTimeoutMs;
|
|
6830
|
+
let image = "";
|
|
6831
|
+
let extra = [];
|
|
6832
|
+
while (Date.now() <= deadline) {
|
|
6833
|
+
image = normalizeQbotCaptchaImage(await imageLocator.getAttribute("src"));
|
|
6834
|
+
extra = extractQbotCaptchaExtra(await extraLocator.textContent());
|
|
6835
|
+
if (image && extra.length > 0) {
|
|
6836
|
+
return { imageLocator, image, extra };
|
|
6837
|
+
}
|
|
6838
|
+
await page.waitForTimeout(config.payloadPollIntervalMs);
|
|
6839
|
+
}
|
|
6825
6840
|
if (!image) {
|
|
6826
6841
|
throw new Error("[Captcha] qbot \u9A8C\u8BC1\u7801\u56FE\u7247\u4E3A\u7A7A\u3002");
|
|
6827
6842
|
}
|
|
6828
|
-
const extraLocator = page.locator(config.extraSelector).first();
|
|
6829
|
-
await extraLocator.waitFor({ state: "visible", timeout: config.extraVisibleTimeoutMs });
|
|
6830
|
-
const extra = extractQbotCaptchaExtra(await extraLocator.textContent());
|
|
6831
6843
|
if (extra.length === 0) {
|
|
6832
6844
|
throw new Error("[Captcha] qbot \u9A8C\u8BC1\u7801 extra \u4E3A\u7A7A\u3002");
|
|
6833
6845
|
}
|