const shareBtn = document.getElementById("share-btn"); shareBtn.addEventListener("click", () => { share(); }); function share() { const data = { title: "altaf-creator", text: document.title, url: window.location, }; iconChange(); navigator.clipboard.writeText(window.location); navigator.share(data); } async function iconChange() { shareBtn.firstChild.setAttribute("class", "fa-solid fa-copy"); await sleep(2000); shareBtn.firstChild.setAttribute("class", "fa-solid fa-share-nodes"); } function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }