function exportAll() { var btn = document.getElementById('export-all-btn'); var buttons = document.querySelectorAll('.export-card button.secondary'); if (buttons.length === 0) return; btn.disabled = true; btn.textContent = 'Exporting...'; var i = 0; function next() { if (i >= buttons.length) { btn.textContent = 'Done'; // A temporary label going back to the real one: `Intent::Revert`, // the same duration a copy button flashes for. setTimeout(function() { btn.textContent = 'Export All'; btn.disabled = false; }, window.timing.revertMs()); return; } buttons[i].click(); i++; // Not a timing intent: this paces one click after another so the // browser is not handed a dozen downloads at once. setTimeout(next, 1500); } next(); }