// «Conversione della libreria» in Impostazioni → Esportazione (spec §4.10, tappa E3; composed from mockups 08 and 07 and // the dialogs of mockup 13): PNG chosen for the photos opens «Convertire anche i N file già in libreria?» with «Solo i // nuovi» first. Nothing is answered: closed, the setting stays «Originale». 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 photo = () => document.querySelector('.sezione-conversione .scelta-formato[data-tipo=photo]'); await until(() => photo() && document.querySelector('.stato-conversione')?.textContent); const body = document.querySelector('.corpo'); const section = document.querySelector('.sezione-conversione'); body.scrollTop = section.getBoundingClientRect().top - body.getBoundingClientRect().top + body.scrollTop - 24; photo().querySelector('[data-value=png]').click(); const question = () => [...document.querySelectorAll('.dialogo')].find((d) => d.querySelector('.spazio-conversione')); await until(question); await sleep(500); document.activeElement?.blur(); return [question().querySelector('h2')?.textContent, question().querySelector('.spazio-conversione')?.textContent];