From 521d43f2bbb72c27b60c69ed63f1b6446855a5fc Mon Sep 17 00:00:00 2001 From: volovikariel <16262535+volovikariel@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:29:18 -0400 Subject: [PATCH] Switched from deprecated document.execCommand to the clipboard API --- interface/options/options.js | 10 +--------- interface/popup/cookie-list.js | 10 +--------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/interface/options/options.js b/interface/options/options.js index eb1af45..e05378b 100644 --- a/interface/options/options.js +++ b/interface/options/options.js @@ -199,15 +199,7 @@ document.addEventListener('DOMContentLoaded', async (event) => { * @param {string} text Text to copy. */ function copyText(text) { - const fakeText = document.createElement('textarea'); - fakeText.classList.add('clipboardCopier'); - fakeText.textContent = text; - document.body.appendChild(fakeText); - fakeText.focus(); - fakeText.select(); - // TODO: switch to clipboard API. - document.execCommand('Copy'); - document.body.removeChild(fakeText); + navigator.clipboard.writeText(text); } /** diff --git a/interface/popup/cookie-list.js b/interface/popup/cookie-list.js index a1335d3..f8c4b1f 100644 --- a/interface/popup/cookie-list.js +++ b/interface/popup/cookie-list.js @@ -1202,15 +1202,7 @@ import { CookieHandlerPopup } from './cookieHandlerPopup.js'; * @param {string} text Text to copy. */ function copyText(text) { - const fakeText = document.createElement('textarea'); - fakeText.classList.add('clipboardCopier'); - fakeText.textContent = text; - document.body.appendChild(fakeText); - fakeText.focus(); - fakeText.select(); - // TODO: switch to clipboard API. - document.execCommand('Copy'); - document.body.removeChild(fakeText); + navigator.clipboard.writeText(text); } /**