From 70d4918e7256ffb485d787585bf74ab85844431f Mon Sep 17 00:00:00 2001 From: gravel Date: Mon, 22 May 2023 17:03:23 +0200 Subject: [PATCH] Add failure message for clipboard copy --- output/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/output/main.js b/output/main.js index b43dd21..eddaf96 100644 --- a/output/main.js +++ b/output/main.js @@ -295,7 +295,11 @@ function hideElementByID(id) { * @param {string} [toastText] - Text shown by toast. */ function copyToClipboard(text, toastText = JOIN_URL_PASTE) { - navigator.clipboard.writeText(text); + if (typeof navigator.clipboard !== "undefined") { + navigator.clipboard.writeText(text); + } else { + toastText = "Can not copy to clipboard in insecure context."; + } // Find snackbar element const snackbar = dom.snackbar();