evaluate-script
Execute JavaScript scripts within AdsPower browser profiles to automate interactions, modify page elements, or perform custom browser operations.
Instructions
Evaluate the script
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | The script to evaluate, eg: "document.querySelector('#username').value = 'test'" |
Implementation Reference
- src/handlers/automation.ts:132-136 (handler)The main handler function for the 'evaluate-script' tool, which evaluates the provided JavaScript script in the current browser page context using Puppeteer.async evaluateScript({ script }: EvaluateScriptParams) { browser.checkConnected(); const result = await browser.pageInstance!.evaluate(script); return result; },
- src/types/schemas.ts:209-211 (schema)Zod schema defining the input for the evaluate-script tool, requiring a 'script' string parameter.evaluateScriptSchema: z.object({ script: z.string().describe('The script to evaluate, eg: "document.querySelector(\'#username\').value = \'test\'"') }).strict(),
- src/utils/toolRegister.ts:86-87 (registration)Registration of the 'evaluate-script' tool on the MCP server, linking name, description, schema, and wrapped handler.server.tool('evaluate-script', 'Evaluate the script', schemas.evaluateScriptSchema.shape, wrapHandler(automationHandlers.evaluateScript));