Is your feature request related to a problem? Please describe.
I need the ability to inject scripts early on a page's lifecycle.
This means the evaluate_script tool is not useful for me as it executes too late.
Describe the solution you'd like
Puppeteer has a method page.evaluateOnNewDocument that seems to do exactly what I want.
I did a small POC adding it as a param to navigate_page:
...
initScript: zod.string().optional().describe(
`(optional) A JavaScript function declaration to be executed by the tool on new document for every page load.
`),
...
...
if(request.params.initScript){
page.evaluateOnNewDocument(request.params.initScript);
}
...
Describe alternatives you've considered
One approach would be to have a new "tool" but I think having it as an option on navigate makes more sense here as it's just enhancing that workflow.
Additional context
No response
Is your feature request related to a problem? Please describe.
I need the ability to inject scripts early on a page's lifecycle.
This means the
evaluate_scripttool is not useful for me as it executes too late.Describe the solution you'd like
Puppeteer has a method
page.evaluateOnNewDocumentthat seems to do exactly what I want.I did a small POC adding it as a param to navigate_page:
... initScript: zod.string().optional().describe( `(optional) A JavaScript function declaration to be executed by the tool on new document for every page load. `), ...... if(request.params.initScript){ page.evaluateOnNewDocument(request.params.initScript); } ...Describe alternatives you've considered
One approach would be to have a new "tool" but I think having it as an option on navigate makes more sense here as it's just enhancing that workflow.
Additional context
No response