browser_evaluate
Execute arbitrary JavaScript code in the page context. Has full access to the DOM, window object, and all page JavaScript. Use return_value=true to get the result of an expression.
Usage Example
Parameters
Required
context_idstringrequiredThe unique identifier of the browser context (e.g., 'ctx_000001')
Optional
scriptstringJavaScript code to execute in the page context. Can access DOM, window object, etc. Example: 'document.title' or 'window.scrollY'. Optional if expression is provided.
expressionstringJavaScript expression to evaluate and return (shorthand for script with return_value=true). If provided, script is optional and return_value is automatically true.
return_valuebooleanIf true, treats the script as an expression and returns its value. If false (default), executes the script as statements. Automatically set to true when using expression.
Response
Returns a JSON object with the operation result.
{
"success": true,
"result": <value>
}