diff --git a/js/settings.js b/js/settings.js index 1937c41..9c86aaa 100644 --- a/js/settings.js +++ b/js/settings.js @@ -193,28 +193,31 @@ async function generateUrl() { } async function copyUrl() { + + const output = document.getElementById("outputUrl") + const value = output.value; - const output = document.getElementById("outputUrl"); - - output.select(); - document.execCommand("copy"); - const button = document.querySelector('.url-bar button'); const buttonDefaulText = 'Copy URL'; - button.textContent = 'ChatRD URL Copied!'; - button.style.backgroundColor = "#00dd63"; + navigator.clipboard.writeText(value) + .then(() => { - setTimeout(() => { - button.textContent = buttonDefaulText; - button.removeAttribute('style'); - }, 3000); + button.textContent = 'ChatRD URL Copied!'; + button.style.backgroundColor = "#00dd63"; + setTimeout(() => { + button.textContent = buttonDefaulText; + button.removeAttribute('style'); + }, 3000); + }) + .catch(err => { + console.error("Failed to copy: ", err); + }); } - async function setupAddEmoteModal() { const modal = document.getElementById("addEmoteModal"); const nameInput = document.getElementById("newEmoteName"); @@ -366,4 +369,4 @@ document.querySelectorAll('.nav-bar a').forEach(anchor => { }); } }); -}); \ No newline at end of file +});