// «Cerca i video fermi» from the selection bar of the Libreria (spec §4.10, tappa E4; composed from the dialogs of // mockup 13): @marta.demo, «Seleziona», five tiles of videos (some already analysed) and four of photos, then the // confirmation with its counts. Nothing starts. const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); const until = async (test, tries = 100) => { for (let i = 0; i < tries && !test(); i++) await sleep(100); return test(); }; const tiles = () => [...document.querySelectorAll('.mosaico .tess[data-id]')]; const isVideo = (tile) => Boolean(tile.querySelector('use[href="#i-play"]')); await until(() => tiles().filter(isVideo).length >= 5 && tiles().length >= 9); [...document.querySelectorAll('.strumenti .btn')].find((b) => b.textContent.includes('Seleziona')).click(); await sleep(300); const chosen = [...tiles().filter(isVideo).slice(0, 5), ...tiles().filter((x) => !isVideo(x)).slice(0, 4)]; for (const tile of chosen) { tile.click(); await sleep(60); } const search = () => document.querySelector('.salva .fermi-selezione'); await until(() => search() && !search().disabled); search().click(); const dialog = () => document.querySelector('.dialogo.cerca-fermi'); await until(() => dialog()?.querySelector('.riepilogo-copia')); await sleep(500); document.activeElement?.blur(); return dialog().querySelector('.riepilogo-fermi').textContent;