@skrillex1224/playwright-toolkit 3.0.53 → 3.0.55
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 +19 -6
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +19 -6
- package/dist/index.js.map +2 -2
- package/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6782,11 +6782,14 @@ 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,
|
|
6788
6790
|
coordinateBaseWidth: QBOT_IMAGE_BASE_WIDTH,
|
|
6789
6791
|
coordinateBaseHeight: QBOT_IMAGE_BASE_HEIGHT,
|
|
6792
|
+
coordinateYOffsetPx: -10,
|
|
6790
6793
|
clickIntervalMs: 250,
|
|
6791
6794
|
refreshVisibleTimeoutMs: 1e3,
|
|
6792
6795
|
refreshWaitMs: 1e3,
|
|
@@ -6801,6 +6804,7 @@ var parseQbotCaptchaCoordinates = (value = "") => String(value || "").split("|")
|
|
|
6801
6804
|
const [x, y] = pair.split(",").map(Number);
|
|
6802
6805
|
return Number.isFinite(x) && Number.isFinite(y) ? { x, y } : null;
|
|
6803
6806
|
}).filter(Boolean);
|
|
6807
|
+
var normalizeQbotCaptchaExtraPayload = (extra = []) => Array.isArray(extra) ? extra.join(",") : String(extra || "");
|
|
6804
6808
|
async function solveQbotCaptcha(image, extra = [], token, options = {}, dependencies = {}) {
|
|
6805
6809
|
const { callCaptchaRecognitionApi: callCaptchaRecognitionApi2 } = dependencies;
|
|
6806
6810
|
if (!token) {
|
|
@@ -6814,20 +6818,29 @@ async function solveQbotCaptcha(image, extra = [], token, options = {}, dependen
|
|
|
6814
6818
|
token,
|
|
6815
6819
|
type: QBOT_CAPTCHA_TYPE,
|
|
6816
6820
|
image,
|
|
6817
|
-
extra
|
|
6821
|
+
extra: normalizeQbotCaptchaExtraPayload(extra)
|
|
6818
6822
|
});
|
|
6819
6823
|
return response?.data?.data ?? response?.data;
|
|
6820
6824
|
}
|
|
6821
6825
|
var readQbotCaptcha = async (page, config) => {
|
|
6822
6826
|
const imageLocator = page.locator(config.imageSelector).first();
|
|
6823
6827
|
await imageLocator.waitFor({ state: "visible", timeout: config.imageVisibleTimeoutMs });
|
|
6824
|
-
const
|
|
6828
|
+
const extraLocator = page.locator(config.extraSelector).first();
|
|
6829
|
+
await extraLocator.waitFor({ state: "visible", timeout: config.extraVisibleTimeoutMs });
|
|
6830
|
+
const deadline = Date.now() + config.payloadReadyTimeoutMs;
|
|
6831
|
+
let image = "";
|
|
6832
|
+
let extra = [];
|
|
6833
|
+
while (Date.now() <= deadline) {
|
|
6834
|
+
image = normalizeQbotCaptchaImage(await imageLocator.getAttribute("src"));
|
|
6835
|
+
extra = extractQbotCaptchaExtra(await extraLocator.textContent());
|
|
6836
|
+
if (image && extra.length > 0) {
|
|
6837
|
+
return { imageLocator, image, extra };
|
|
6838
|
+
}
|
|
6839
|
+
await page.waitForTimeout(config.payloadPollIntervalMs);
|
|
6840
|
+
}
|
|
6825
6841
|
if (!image) {
|
|
6826
6842
|
throw new Error("[Captcha] qbot \u9A8C\u8BC1\u7801\u56FE\u7247\u4E3A\u7A7A\u3002");
|
|
6827
6843
|
}
|
|
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
6844
|
if (extra.length === 0) {
|
|
6832
6845
|
throw new Error("[Captcha] qbot \u9A8C\u8BC1\u7801 extra \u4E3A\u7A7A\u3002");
|
|
6833
6846
|
}
|
|
@@ -6843,7 +6856,7 @@ var clickQbotPoints = async (page, imageLocator, coordinates, config, deviceInpu
|
|
|
6843
6856
|
for (const point of coordinates) {
|
|
6844
6857
|
await deviceInput.clickPoint(page, {
|
|
6845
6858
|
x: box.x + point.x * scaleX,
|
|
6846
|
-
y: box.y + point.y * scaleY
|
|
6859
|
+
y: box.y + point.y * scaleY + config.coordinateYOffsetPx
|
|
6847
6860
|
}, config);
|
|
6848
6861
|
if (config.clickIntervalMs > 0) {
|
|
6849
6862
|
await page.waitForTimeout(config.clickIntervalMs);
|