Skip to content

The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.

fix(ego-browser): make synthetic wheel fallback actually scroll the page

0x0142b2cf2fa3c
diff --git a/package/ego-browser/src/driver/pointer.ts b/package/ego-browser/src/driver/pointer.ts
index b126d19..83b36b3 100644
--- a/package/ego-browser/src/driver/pointer.ts
+++ b/package/ego-browser/src/driver/pointer.ts
@@ -478,9 +478,11 @@ async function isVisibleAndFocused() {
}
/**
- * Dispatch a synthetic WheelEvent on the element under (x, y). Used when the tab
- * is backgrounded/unfocused and CDP wheel input would be dropped. Triggers page
- * wheel handlers (virtualized lists, custom scrollers).
+ * Dispatch a synthetic WheelEvent on the element under (x, y), then perform the
+ * native scroll. Used when the tab is backgrounded/unfocused and CDP wheel input
+ * would be dropped. The WheelEvent triggers page wheel handlers (virtualized
+ * lists, custom scrollers); the window.scrollBy actually moves an ordinary page,
+ * since an untrusted WheelEvent does not perform the default scroll action.
*/
async function dispatchSyntheticWheel(
x: number,
@@ -500,6 +502,7 @@ async function dispatchSyntheticWheel(
clientX: ${JSON.stringify(x)},
clientY: ${JSON.stringify(y)}
}));
+ window.scrollBy(${JSON.stringify(deltaX)}, ${JSON.stringify(deltaY)});
})()`);
}