mutations
Watch DOM mutations on a CSS selector in real-time (read-only).
Bridge Required
This command requires an active bridge connection.
Usage
Options
| Option | Description | Default |
|---|---|---|
<selector> |
CSS selector of the element to observe | (required) |
--attributes |
Also watch attribute changes | — |
--interval <ms> |
Poll interval in milliseconds | 500 |
--duration <ms> |
Auto-stop after N milliseconds | — |
--json |
Output one JSON object per line | — |
--port <number> |
Bridge port (auto-discover if omitted) | — |
--token <string> |
Bridge token (auto-discover if omitted) | — |
Examples
Watch for child additions/removals
Watch attribute changes too
JSON output for automation
Quick 5-second observation
How It Works
- Patches a
MutationObserverinto the webview targeting the specified selector - Polls the accumulated mutation log at the configured interval
- Formats and outputs each mutation entry
- Disconnects the observer and cleans up global state on exit (Ctrl+C, SIGTERM, or
--duration)
Important Notes
- Always use
--durationin automation to avoid indefinite execution. - The observer watches
childListandsubtreeby default. Add--attributesto also track attribute changes. - If a previous session didn't clean up (e.g., hard kill), the command will warn and drain the existing log.