// «Cerca i video fermi» at work in Dashboard → Esportazione (spec §4.10, §10.3, tappa E4; composed from mockup 06 and the // second step of the import, mockup 09): the search of every video of the library, started from another page (as the // selection does), then the Dashboard as it is after the first videos. From then on the page reads no more of the // progress, so the picture does not change while it is taken; the search itself goes on and ends in a few seconds. The // only step that starts something: its screenshot comes last. const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); const until = async (test, tries = 1000) => { for (let i = 0; i < tries && !test(); i++) await sleep(25); return test(); }; await until(() => document.querySelector('.mosaico .tess[data-id]')); const plain = window.fetch; await plain('/api/still-videos/start', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: 'kind=videos' }) }); const { navigate } = await import('/js/core/shell.js'); await navigate('/dashboard/esportazione'); const bar = () => document.querySelector('.avanzamento-fermi'); await until(() => Number(bar()?.querySelector('[role=progressbar]')?.getAttribute('aria-valuenow')) > 0); window.fetch = (url, options) => (String(url?.url || url).includes('/api/still-videos/progress') ? new Promise(() => {}) : plain(url, options)); await sleep(300); document.activeElement?.blur(); return bar()?.querySelector('.conteggio')?.textContent;