browserclaw 0.9.0 → 0.9.2
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 +47 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +47 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -48,9 +48,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
48
48
|
mod
|
|
49
49
|
));
|
|
50
50
|
|
|
51
|
-
//
|
|
51
|
+
// node_modules/ipaddr.js/lib/ipaddr.js
|
|
52
52
|
var require_ipaddr = __commonJS({
|
|
53
|
-
"
|
|
53
|
+
"node_modules/ipaddr.js/lib/ipaddr.js"(exports$1, module) {
|
|
54
54
|
(function(root) {
|
|
55
55
|
const ipv4Part = "(0?\\d+|0x[a-f0-9]+)";
|
|
56
56
|
const ipv4Regexes = {
|
|
@@ -1388,6 +1388,7 @@ async function launchChrome(opts = {}) {
|
|
|
1388
1388
|
const spawnChrome = () => {
|
|
1389
1389
|
const args = [
|
|
1390
1390
|
`--remote-debugging-port=${String(cdpPort)}`,
|
|
1391
|
+
"--remote-debugging-address=127.0.0.1",
|
|
1391
1392
|
`--user-data-dir=${userDataDir}`,
|
|
1392
1393
|
"--no-first-run",
|
|
1393
1394
|
"--no-default-browser-check",
|
|
@@ -3078,6 +3079,25 @@ async function mouseClickViaPlaywright(opts) {
|
|
|
3078
3079
|
delay: opts.delayMs
|
|
3079
3080
|
});
|
|
3080
3081
|
}
|
|
3082
|
+
var MAX_HOLD_MS = 3e4;
|
|
3083
|
+
async function pressAndHoldViaCdp(opts) {
|
|
3084
|
+
const holdMs = resolveBoundedDelayMs(opts.holdMs ?? 1e3, "holdMs", MAX_HOLD_MS);
|
|
3085
|
+
const page = await getPageForTargetId({ cdpUrl: opts.cdpUrl, targetId: opts.targetId });
|
|
3086
|
+
ensurePageState(page);
|
|
3087
|
+
const pos = { x: opts.x, y: opts.y };
|
|
3088
|
+
const btn = { button: "left", clickCount: 1 };
|
|
3089
|
+
await withPageScopedCdpClient({
|
|
3090
|
+
cdpUrl: opts.cdpUrl,
|
|
3091
|
+
page,
|
|
3092
|
+
targetId: opts.targetId,
|
|
3093
|
+
fn: async (send) => {
|
|
3094
|
+
await send("Input.dispatchMouseEvent", { type: "mouseMoved", ...pos });
|
|
3095
|
+
await send("Input.dispatchMouseEvent", { type: "mousePressed", ...pos, ...btn });
|
|
3096
|
+
await new Promise((r) => setTimeout(r, holdMs));
|
|
3097
|
+
await send("Input.dispatchMouseEvent", { type: "mouseReleased", ...pos, ...btn });
|
|
3098
|
+
}
|
|
3099
|
+
});
|
|
3100
|
+
}
|
|
3081
3101
|
async function clickByTextViaPlaywright(opts) {
|
|
3082
3102
|
const page = await getRestoredPageForTarget(opts);
|
|
3083
3103
|
const timeout = resolveInteractionTimeoutMs(opts.timeoutMs);
|
|
@@ -4926,6 +4946,31 @@ var CrawlPage = class {
|
|
|
4926
4946
|
delayMs: opts?.delayMs
|
|
4927
4947
|
});
|
|
4928
4948
|
}
|
|
4949
|
+
/**
|
|
4950
|
+
* Press and hold at page coordinates using raw CDP events.
|
|
4951
|
+
*
|
|
4952
|
+
* Bypasses Playwright's automation layer by dispatching CDP
|
|
4953
|
+
* `Input.dispatchMouseEvent` directly — useful for anti-bot challenges
|
|
4954
|
+
* that detect automated clicks.
|
|
4955
|
+
*
|
|
4956
|
+
* @param x - X coordinate in CSS pixels
|
|
4957
|
+
* @param y - Y coordinate in CSS pixels
|
|
4958
|
+
* @param opts - Options (holdMs: hold duration, default 1000, max 30000)
|
|
4959
|
+
*
|
|
4960
|
+
* @example
|
|
4961
|
+
* ```ts
|
|
4962
|
+
* await page.pressAndHold(400, 300, { holdMs: 5000 });
|
|
4963
|
+
* ```
|
|
4964
|
+
*/
|
|
4965
|
+
async pressAndHold(x, y, opts) {
|
|
4966
|
+
return pressAndHoldViaCdp({
|
|
4967
|
+
cdpUrl: this.cdpUrl,
|
|
4968
|
+
targetId: this.targetId,
|
|
4969
|
+
x,
|
|
4970
|
+
y,
|
|
4971
|
+
holdMs: opts?.holdMs
|
|
4972
|
+
});
|
|
4973
|
+
}
|
|
4929
4974
|
/**
|
|
4930
4975
|
* Click an element by its visible text content (no snapshot/ref needed).
|
|
4931
4976
|
*
|