Skip to content

Conversation

@gernberg
Copy link

Adds a parameter "initScript" to be used to inject a script into the page load before other scripts execute.
Page.evaluateOnNewDocument

See #567

@gernberg gernberg changed the title Add ability to inject script to run on page load feat: Add ability to inject script to run on page load Nov 17, 2025
**Parameters:**

- **ignoreCache** (boolean) _(optional)_: Whether to ignore cache on reload.
- **initScript** (string) _(optional)_: (optional) A JavaScript function to be executed by the tool on new document for every page load before any other scripts.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR! I have asked a few details on the issue. Do you think the new_page tool could be a better place for the init script? Any thoughts how to remove a previously specified init script and if removing it is needed? For your use case, could it be better to pass an init script for all pages via a CLI argument or do you want the LLM to generate the init script?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't thought that much about the different approaches to be honest.
I would be fine to just close this PR for now as it's very minimal (it's just a snapshot basically of what I'm playing with locally at the moment) and keep the discussions in the issues for now to land on a good / better general solution for the problem I'm trying to solve :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants