document.querySelectorAll('.copy-bibtex').forEach((button) => { button.hidden = false; button.addEventListener('click', async () => { const code = document.getElementById(button.dataset.copy); const status = button.closest('.citation-box').querySelector('.copy-status'); if (!code) return; try { await navigator.clipboard.writeText(code.textContent); status.textContent = 'Copied.'; } catch { const selection = window.getSelection(); if (selection) { const range = document.createRange(); range.selectNodeContents(code); selection.removeAllRanges(); selection.addRange(range); } status.textContent = 'Select and copy the citation manually.'; } }); });