document.addEventListener("DOMContentLoaded", function () { const icons = document.querySelectorAll(".copy-icon"); icons.forEach((icon) => { icon.addEventListener("click", () => { const textToCopy = icon.textContent.trim(); const ta = document.createElement("textarea"); ta.value = textToCopy; ta.style.position = "fixed"; ta.style.opacity = "0"; document.body.appendChild(ta); ta.select(); document.execCommand("copy"); document.body.removeChild(ta); icon.classList.add("copied"); clearTimeout(icon._copiedTimeout); icon._copiedTimeout = setTimeout(() => { icon.classList.remove("copied"); }, 1500); }); }); });