add_init_script
Inject JavaScript to run before page scripts on every navigation for hooking and interception in reverse engineering workflows.
Instructions
Inject a script that runs automatically before any page JavaScript on every navigation.
This is the core method for installing hooks — the hook code runs before the target site's JS loads, ensuring interception is in place.
Args: script: JavaScript code string to inject. path: Path to a .js file to inject (alternative to script). persistent: If True, inject at context level so the script survives page navigation, new tabs, and reload automatically. Recommended for hooks that must always be present. name: Optional identifier for persistent scripts (for later removal).
Returns: dict with status and the method used (inline or file path).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | No | ||
| path | No | ||
| persistent | No | ||
| name | No |