From bd76c3e98549eb360e250e8e73a116b74a6dc9c5 Mon Sep 17 00:00:00 2001 From: chylex Date: Wed, 20 Sep 2017 13:31:13 +0200 Subject: [PATCH] Fix copying tracker to clipboard in unsupported browsers --- web/index.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/index.php b/web/index.php index a737ba4..8a1d41e 100644 --- a/web/index.php +++ b/web/index.php @@ -26,7 +26,7 @@

After adding the script to your bookmarks, open Discord and click the bookmark to run the script. If you run into any issues, please make sure your browser is up-to-date.

...using the Discord app

-

Click Copy to Clipboard to copy the script. Then press Ctrl+Shift+I in the Discord app, select Console, paste the script into the text box at the bottom and press Enter to run it. You can then close the console and continue using the script.

+

Click Copy to Clipboard to copy the script. Then press Ctrl+Shift+I in the Discord app, select Console, paste the script into the text box at the bottom and press Enter to run it. You can then close the console and continue using the script.

What next?

When running for the first time, you will see a Settings dialog where you can configure the script's behavior. These settings will be remembered as long as you don't delete cookies in your browser.

@@ -65,7 +65,15 @@ var ele = document.getElementById("tracker-copy-contents"); ele.style.display = "block"; ele.select(); - document.execCommand("copy"); + + try{ + if (!document.execCommand("copy")){ + throw null; + } + }catch(e){ + prompt("Press CTRL+C to copy the script:", ele.value); + } + ele.style.display = "none"; });