From 648b6aac4ed9aaf0d3795ed3fb84ef11ccbe44cb Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Mon, 4 Apr 2022 11:59:26 -0700 Subject: [PATCH] feat: :sparkles: Share button = copy to clipboard if no sharenav --- frontend/src/index.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/src/index.ts b/frontend/src/index.ts index 2bb1a91..6dcd0f7 100755 --- a/frontend/src/index.ts +++ b/frontend/src/index.ts @@ -167,16 +167,19 @@ function viewPaste(content: string, views: string, singleView: boolean) { addMessage("This is a single-view paste!") } - if (navigator.canShare) { - show(shareButton) - - shareButton.addEventListener("click", function () { + show(shareButton) + shareButton.addEventListener("click", function () { + const url = window.location.toString() + if (navigator.canShare) { navigator.share({ title: "zer0bin paste", - url: window.location.toString(), + url: url, }) - }) - } + } else { + navigator.clipboard.writeText(url) + addMessage("Copied URL to clipboard!") + } + }) disable(saveButton) disable(markdownButton)