// «Automatica» in the dialog of the general folder of Impostazioni → Esportazione (spec §4.10, tappa E5; composed from // the dialogs of mockup 13): the switch turned on asks «Che cosa fare dei file già in libreria?» with «Solo i nuovi» // first and «Copia anche i N già in libreria». Nothing is saved: closed, the folder stays as it was. const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); const until = async (test, tries = 300) => { for (let i = 0; i < tries && !test(); i++) await sleep(100); return test(); }; const edit = () => [...document.querySelectorAll('.cartella-impostazioni .btn')].find((b) => b.textContent.includes('Modifica')); await until(edit); edit().click(); const dialog = () => document.querySelector('.dialogo.destinazione'); const part = () => dialog() && dialog().querySelector('.parte-automatica'); await until(() => part() && /liberi/.test(dialog().querySelector('.controllo-cartella')?.textContent || '')); part().querySelector('input[role=switch]').click(); // The count of the files already in the library takes a few seconds on the demo's 18.000 entries. await until(() => part().querySelectorAll('input[name=automatica-esistenti]').length === 2); part().scrollIntoView({ block: 'end' }); await sleep(500); document.activeElement?.blur(); return part().querySelector('.automatica-scelta')?.textContent;