function copy(text, tooltip) { return () => { navigator.clipboard.writeText(text); tooltip.textContent = " []"; setTimeout(() => (tooltip.textContent = " []"), 1000); }; } window.onload = () => { document.querySelectorAll(".copy").forEach((element) => { const tooltip = document.createElement("span"); tooltip.classList.add("copy-button"); tooltip.textContent = " []"; element.onclick = copy(element.attributes["copy-text"]?.value, tooltip); element.appendChild(tooltip); }); };