@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.js CHANGED
@@ -6754,6 +6754,8 @@ 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,
@@ -6773,6 +6775,7 @@ var parseQbotCaptchaCoordinates = (value = "") => String(value || "").split("|")
6773
6775
  const [x, y] = pair.split(",").map(Number);
6774
6776
  return Number.isFinite(x) && Number.isFinite(y) ? { x, y } : null;
6775
6777
  }).filter(Boolean);
6778
+ var normalizeQbotCaptchaExtraPayload = (extra = []) => Array.isArray(extra) ? extra.join(",") : String(extra || "");
6776
6779
  async function solveQbotCaptcha(image, extra = [], token, options = {}, dependencies = {}) {
6777
6780
  const { callCaptchaRecognitionApi: callCaptchaRecognitionApi2 } = dependencies;
6778
6781
  if (!token) {
@@ -6786,20 +6789,29 @@ async function solveQbotCaptcha(image, extra = [], token, options = {}, dependen
6786
6789
  token,
6787
6790
  type: QBOT_CAPTCHA_TYPE,
6788
6791
  image,
6789
- extra
6792
+ extra: normalizeQbotCaptchaExtraPayload(extra)
6790
6793
  });
6791
6794
  return response?.data?.data ?? response?.data;
6792
6795
  }
6793
6796
  var readQbotCaptcha = async (page, config) => {
6794
6797
  const imageLocator = page.locator(config.imageSelector).first();
6795
6798
  await imageLocator.waitFor({ state: "visible", timeout: config.imageVisibleTimeoutMs });
6796
- const image = normalizeQbotCaptchaImage(await imageLocator.getAttribute("src"));
6799
+ const extraLocator = page.locator(config.extraSelector).first();
6800
+ await extraLocator.waitFor({ state: "visible", timeout: config.extraVisibleTimeoutMs });
6801
+ const deadline = Date.now() + config.payloadReadyTimeoutMs;
6802
+ let image = "";
6803
+ let extra = [];
6804
+ while (Date.now() <= deadline) {
6805
+ image = normalizeQbotCaptchaImage(await imageLocator.getAttribute("src"));
6806
+ extra = extractQbotCaptchaExtra(await extraLocator.textContent());
6807
+ if (image && extra.length > 0) {
6808
+ return { imageLocator, image, extra };
6809
+ }
6810
+ await page.waitForTimeout(config.payloadPollIntervalMs);
6811
+ }
6797
6812
  if (!image) {
6798
6813
  throw new Error("[Captcha] qbot \u9A8C\u8BC1\u7801\u56FE\u7247\u4E3A\u7A7A\u3002");
6799
6814
  }
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
6815
  if (extra.length === 0) {
6804
6816
  throw new Error("[Captcha] qbot \u9A8C\u8BC1\u7801 extra \u4E3A\u7A7A\u3002");
6805
6817
  }