@skrillex1224/playwright-toolkit 2.1.32 → 2.1.33
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 +9 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +9 -4
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -684,7 +684,7 @@ var Humanize = {
|
|
|
684
684
|
* @param {number} [options.maxStep=220] - 单次滚动最大步长
|
|
685
685
|
*/
|
|
686
686
|
async humanScroll(page, target, options = {}) {
|
|
687
|
-
const { maxSteps = 30, minStep =
|
|
687
|
+
const { maxSteps = 30, minStep = 150, maxStep = 400 } = options;
|
|
688
688
|
const targetDesc = typeof target === "string" ? target : "ElementHandle";
|
|
689
689
|
logger4.debug(`humanScroll | \u76EE\u6807=${targetDesc}`);
|
|
690
690
|
let element;
|
|
@@ -722,7 +722,10 @@ var Humanize = {
|
|
|
722
722
|
tag: pointElement.tagName,
|
|
723
723
|
id: pointElement.id,
|
|
724
724
|
className: pointElement.className
|
|
725
|
-
}
|
|
725
|
+
},
|
|
726
|
+
cy,
|
|
727
|
+
// Return Center Y for smart direction calculation
|
|
728
|
+
viewH
|
|
726
729
|
};
|
|
727
730
|
}
|
|
728
731
|
return { code: "VISIBLE" };
|
|
@@ -749,7 +752,9 @@ var Humanize = {
|
|
|
749
752
|
deltaY = 100;
|
|
750
753
|
}
|
|
751
754
|
} else if (status.code === "OBSTRUCTED") {
|
|
752
|
-
|
|
755
|
+
const isBottomHalf = status.cy > status.viewH / 2;
|
|
756
|
+
const direction = isBottomHalf ? 1 : -1;
|
|
757
|
+
deltaY = direction * (minStep + Math.random() * 50);
|
|
753
758
|
}
|
|
754
759
|
if (i === 0 || Math.random() < 0.2) {
|
|
755
760
|
const viewSize = page.viewportSize();
|
|
@@ -761,7 +766,7 @@ var Humanize = {
|
|
|
761
766
|
}
|
|
762
767
|
await page.mouse.wheel(0, deltaY);
|
|
763
768
|
didScroll = true;
|
|
764
|
-
await (0, import_delay2.default)(this.jitterMs(
|
|
769
|
+
await (0, import_delay2.default)(this.jitterMs(100 + Math.random() * 150, 0.2));
|
|
765
770
|
}
|
|
766
771
|
logger4.warn(`humanScroll | \u5728 ${maxSteps} \u6B65\u540E\u65E0\u6CD5\u786E\u4FDD\u53EF\u89C1\u6027`);
|
|
767
772
|
return { element, didScroll };
|