observe
Monitor DOM elements for changes using collect or until modes. Collect all text/attribute changes over a set duration, or wait for a condition and click instantly. Replaces hand-written MutationObserver or setInterval code.
Instructions
Watch an element for changes over time — use this INSTEAD of writing MutationObserver/setInterval/setTimeout code in evaluate. Two modes: (1) collect — watch for 'duration' ms, return all text/attribute changes (e.g. collect 3 values that appear one after another). (2) until — wait for a condition, then optionally click immediately (e.g. click Capture when counter hits 8). Use click_first to trigger the action that causes changes (observer is set up BEFORE the click, so nothing is missed).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| until | No | JS expression evaluated on each change — stops when it returns true. Variable 'el' is the observed element. Example: el.textContent === '8' | |
| collect | No | What to collect: 'text' for textContent changes, 'attributes' for attribute changes, 'all' for both (default: 'text') | text |
| timeout | No | Maximum observation time in ms (default: 10000, max: 25000) | |
| duration | No | Collect all changes for this many ms, then return them. Mutually exclusive with 'until'. Default: 5000 | |
| interval | No | Polling interval in ms for change detection fallback (default: 100) | |
| selector | Yes | CSS selector or element ref (e.g. 'e5') of the element to observe | |
| then_click | No | CSS selector or element ref (e.g. 'e5') to click immediately when 'until' condition is met (for timing-critical actions). Only used with 'until'. | |
| click_first | No | CSS selector or element ref (e.g. 'e5') to click AFTER the observer is set up but BEFORE collection starts. Use to trigger the changes you want to observe (e.g. 'Start Mutations' button). |