browser_eval
Execute custom JavaScript in the browser page context to read state, manipulate the DOM, or trigger events that standard tools don't cover, returning the serialized result.
Instructions
Execute JavaScript in the page context and return the result. This is your ESCAPE HATCH for anything the other tools don't cover. Common use cases: • Read computed styles: getComputedStyle(el).backgroundColor • Append text to inputs without clearing: el.value += '...'; el.dispatchEvent(new Event('input', {bubbles:true})) • Type character-by-character for autocomplete: use dispatchEvent with input events per character • Drag-and-drop: create and dispatch mousedown/mousemove/mouseup or dragstart/drop events • Read JS app state: window.store, React devtools, etc. • Check visibility via CSS: getComputedStyle(el).display, opacity, visibility • Scroll inside a container: document.querySelector('.container').scrollTop += 500 The code is evaluated as an expression — use an IIFE for multi-statement code.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript code to evaluate in the page. For async code use: (async () => { ... })(). Return value is serialized as JSON. |