@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.js
CHANGED
|
@@ -6754,11 +6754,14 @@ var DEFAULT_QBOT_PAGE_OPTIONS = Object.freeze({
|
|
|
6754
6754
|
formVisibleTimeoutMs: 1e4,
|
|
6755
6755
|
imageVisibleTimeoutMs: 1e4,
|
|
6756
6756
|
extraVisibleTimeoutMs: 5e3,
|
|
6757
|
+
payloadReadyTimeoutMs: 1e4,
|
|
6758
|
+
payloadPollIntervalMs: 200,
|
|
6757
6759
|
vcSelector: "#vc",
|
|
6758
6760
|
vcValueTimeoutMs: 8e3,
|
|
6759
6761
|
submitLoadTimeoutMs: 3e4,
|
|
6760
6762
|
coordinateBaseWidth: QBOT_IMAGE_BASE_WIDTH,
|
|
6761
6763
|
coordinateBaseHeight: QBOT_IMAGE_BASE_HEIGHT,
|
|
6764
|
+
coordinateYOffsetPx: -10,
|
|
6762
6765
|
clickIntervalMs: 250,
|
|
6763
6766
|
refreshVisibleTimeoutMs: 1e3,
|
|
6764
6767
|
refreshWaitMs: 1e3,
|
|
@@ -6773,6 +6776,7 @@ var parseQbotCaptchaCoordinates = (value = "") => String(value || "").split("|")
|
|
|
6773
6776
|
const [x, y] = pair.split(",").map(Number);
|
|
6774
6777
|
return Number.isFinite(x) && Number.isFinite(y) ? { x, y } : null;
|
|
6775
6778
|
}).filter(Boolean);
|
|
6779
|
+
var normalizeQbotCaptchaExtraPayload = (extra = []) => Array.isArray(extra) ? extra.join(",") : String(extra || "");
|
|
6776
6780
|
async function solveQbotCaptcha(image, extra = [], token, options = {}, dependencies = {}) {
|
|
6777
6781
|
const { callCaptchaRecognitionApi: callCaptchaRecognitionApi2 } = dependencies;
|
|
6778
6782
|
if (!token) {
|
|
@@ -6786,20 +6790,29 @@ async function solveQbotCaptcha(image, extra = [], token, options = {}, dependen
|
|
|
6786
6790
|
token,
|
|
6787
6791
|
type: QBOT_CAPTCHA_TYPE,
|
|
6788
6792
|
image,
|
|
6789
|
-
extra
|
|
6793
|
+
extra: normalizeQbotCaptchaExtraPayload(extra)
|
|
6790
6794
|
});
|
|
6791
6795
|
return response?.data?.data ?? response?.data;
|
|
6792
6796
|
}
|
|
6793
6797
|
var readQbotCaptcha = async (page, config) => {
|
|
6794
6798
|
const imageLocator = page.locator(config.imageSelector).first();
|
|
6795
6799
|
await imageLocator.waitFor({ state: "visible", timeout: config.imageVisibleTimeoutMs });
|
|
6796
|
-
const
|
|
6800
|
+
const extraLocator = page.locator(config.extraSelector).first();
|
|
6801
|
+
await extraLocator.waitFor({ state: "visible", timeout: config.extraVisibleTimeoutMs });
|
|
6802
|
+
const deadline = Date.now() + config.payloadReadyTimeoutMs;
|
|
6803
|
+
let image = "";
|
|
6804
|
+
let extra = [];
|
|
6805
|
+
while (Date.now() <= deadline) {
|
|
6806
|
+
image = normalizeQbotCaptchaImage(await imageLocator.getAttribute("src"));
|
|
6807
|
+
extra = extractQbotCaptchaExtra(await extraLocator.textContent());
|
|
6808
|
+
if (image && extra.length > 0) {
|
|
6809
|
+
return { imageLocator, image, extra };
|
|
6810
|
+
}
|
|
6811
|
+
await page.waitForTimeout(config.payloadPollIntervalMs);
|
|
6812
|
+
}
|
|
6797
6813
|
if (!image) {
|
|
6798
6814
|
throw new Error("[Captcha] qbot \u9A8C\u8BC1\u7801\u56FE\u7247\u4E3A\u7A7A\u3002");
|
|
6799
6815
|
}
|
|
6800
|
-
const extraLocator = page.locator(config.extraSelector).first();
|
|
6801
|
-
await extraLocator.waitFor({ state: "visible", timeout: config.extraVisibleTimeoutMs });
|
|
6802
|
-
const extra = extractQbotCaptchaExtra(await extraLocator.textContent());
|
|
6803
6816
|
if (extra.length === 0) {
|
|
6804
6817
|
throw new Error("[Captcha] qbot \u9A8C\u8BC1\u7801 extra \u4E3A\u7A7A\u3002");
|
|
6805
6818
|
}
|
|
@@ -6815,7 +6828,7 @@ var clickQbotPoints = async (page, imageLocator, coordinates, config, deviceInpu
|
|
|
6815
6828
|
for (const point of coordinates) {
|
|
6816
6829
|
await deviceInput.clickPoint(page, {
|
|
6817
6830
|
x: box.x + point.x * scaleX,
|
|
6818
|
-
y: box.y + point.y * scaleY
|
|
6831
|
+
y: box.y + point.y * scaleY + config.coordinateYOffsetPx
|
|
6819
6832
|
}, config);
|
|
6820
6833
|
if (config.clickIntervalMs > 0) {
|
|
6821
6834
|
await page.waitForTimeout(config.clickIntervalMs);
|