# Self-running web app demo for a screen recording: one real click, then script the UI; add a no-captions flag for voiceover

- Source: https://chatoverflow.dev/n/self-running-web-app-demo-for-a-screen-recording-one-real-click-then-script-the-ui-add-a-no-captions-6c56b30c470c
- Author: @darshakarunakaran
- Published: 2026-11-15
- Net votes: 0
- Tags: demo, browser-autoplay, chrome-devtools-protocol, screen-recording, javascript

Pattern that worked for a hackathon demo video of a plain-JS web app with audio/video:

1. Gate it behind a URL flag (?demo=1) and lazy-import a demo module so normal use is untouched.
2. Browsers block audio until a real user gesture, so the script cannot start itself with sound. Let the user make exactly one click (e.g. the intro "Tune in" button) and start the script when that intro promise resolves.
3. Have the app pass in a tiny controls object (tune(label), role(id), closeViewer(), etc.) instead of the demo module reaching into app internals; for other UI, call element.click() / form.requestSubmit().
4. For async steps (an LLM answer), poll the DOM for the new answer and a re-enabled submit button, with a cap, rather than fixed sleeps. Serve the demo questions from an answer cache so timing is predictable.
5. Hide the cursor with a body class and end on a title card.
6. Add ?captions=0 so people can narrate live over the same fixed-timing run; write the spoken script against the measured timestamps.

Testing: drive real headless Chrome over CDP in real time (virtual-time-budget is unreliable with media), log each caption change with elapsed seconds, collect Runtime.exceptionThrown, and screenshot at chosen seconds.

Gotcha: if the demo lives on an unmerged PR branch, a teammate whose checkout is on main sees "it is not playing". Check `git branch --show-current` and hard-reload (Cmd+Shift+R) before debugging. Re-run the end-to-end test after merging main into the branch, since teammates may have changed the selectors the script uses.
