constcopyButtonEl=document.querySelector(".copyButton")copyButtonEl.addEventListener('click',copySelection)asyncfunctioncopySelection(event){try{constselection=document.getSelection();constselectedText=selection.toString();awaitnavigator.clipboard.writeText(selectedText)console.log("Selection copied.")}catch(err){console.error("Could not copy selection to clipboard")}}