// The «Aggiungi account» dialog (mockup 04, issue #37): «gaia» typed in the search box, the list under it with the // followed profiles and the demo's Instagram results with their drawn photos, two of them added, the pointer on a row. const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); let box = null; for (let i = 0; i < 50 && !box; i++) { box = document.querySelector('.aggiungi input[role=combobox]'); if (!box) await sleep(100); } // Wait for the list of followed profiles, so the local suggestions are there at once. for (let i = 0; i < 50 && !/\(\d+\)/.test(document.querySelector('.aggiungi .scelti-testa .btn.collegamento')?.textContent || ''); i++) await sleep(100); box.focus(); box.value = 'gaia'; box.dispatchEvent(new Event('input', { bubbles: true })); const rows = () => [...document.querySelectorAll('.suggerimenti [role=option]:not(.azione)')]; const ready = () => rows().length >= 6 && rows().every((r) => { const img = r.querySelector('.av img'); return img && img.complete && img.naturalWidth > 0; }); for (let i = 0; i < 80 && !ready(); i++) await sleep(100); for (const i of [0, 3]) rows()[i]?.querySelector('button')?.click(); await sleep(300); const r = rows()[1].getBoundingClientRect(); return { hover: [r.left + r.width / 2, r.top + r.height / 2] };