Skip to content

Conversation

@ling0x
Copy link
Contributor

@ling0x ling0x commented Dec 7, 2025

Fixes #205

The existing evaluate_on_new_document method already provides the functionality of Playwright’s addInitScript, injecting JavaScript before any page scripts load. This method maps directly to Chrome DevTools Protocol’s Page.addScriptToEvaluateOnNewDocument command.

Although different tools use different names, Playwright calls it addInitScript, Puppeteer uses evaluateOnNewDocument, they all achieve the same goal: running initialization scripts ahead of page execution (e.g., to hide navigator.webdriver).

Added:

  • Expanded documentation and example for evaluate_on_new_document and add_init_script.
  • add_init_script added as an alias for evaluate_on_new_document for better discoverability.

@Sytten
Copy link
Collaborator

Sytten commented Dec 7, 2025

Seems reasonable to me, I just want to start adding integration tests before expanding the API further to reduce maintenance burden.

@Sytten
Copy link
Collaborator

Sytten commented Dec 8, 2025

Thanks! Running the test and will merge once it passes.

@Sytten Sytten merged commit f848ee5 into mattsse:main Dec 15, 2025
10 checks passed
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.

Running an init script

2 participants