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) | — |
--pid <number> |
Select an app bridge by PID | — |
--window-label <label> |
Select a webview | main |
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. - Sessions use separate observers and buffers, so different selectors and simultaneous subscribers do not share or drain each other’s events.
Each invocation has an independent session with a 1,000-entry buffer. Overflow is reported on stderr. The collector takes a final sample even when --duration is shorter than --interval, and removes its own instrumentation on completion, failure, SIGINT, or SIGTERM while the webview remains reachable. Force-killing the CLI or losing the webview can prevent cleanup. Intervals and durations must be positive whole milliseconds.
Use --duration in automation. With --json, entries are NDJSON on stdout; warnings and fatal errors go to stderr.