observe
Monitor DOM element changes: collect text or attribute modifications over time, or wait for a condition to trigger an action. Use instead of MutationObserver or polling.
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 |
|---|---|---|---|
| selector | Yes | CSS selector or element ref (e.g. 'e5') of the element to observe | |
| duration | No | Collect all changes for this many ms, then return them. Mutually exclusive with 'until'. Default: 5000 | |
| until | No | JS expression evaluated on each change — stops when it returns true. Variable 'el' is the observed element. Example: el.textContent === '8' | |
| 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). | |
| collect | No | What to collect: 'text' for textContent changes, 'attributes' for attribute changes, 'all' for both (default: 'text') | text |
| interval | No | Polling interval in ms for change detection fallback (default: 100) | |
| timeout | No | Maximum observation time in ms (default: 10000, max: 25000) |