From 85e9c5a0a4e7d5268eda068bd3837db4b50f0eb7 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 29 Mar 2022 15:53:18 +0200 Subject: [PATCH] added copy link action --- src/view.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/view.ts b/src/view.ts index c396f8b..6f027a8 100644 --- a/src/view.ts +++ b/src/view.ts @@ -5,13 +5,19 @@ export class CustomFrameView extends ItemView { private static readonly actions: Action[] = [ { - name: "Open dev tools", - icon: "binary", - action: v => v.toggleDevTools() - }, { name: "Return to original page", icon: "home", action: v => v.return() + }, + { + name: "Open dev tools", + icon: "binary", + action: v => v.toggleDevTools() + }, + { + name: "Copy link", + icon: "link", + action: v => v.copyLink() }, { name: "Refresh", icon: "refresh-cw", @@ -140,6 +146,11 @@ export class CustomFrameView extends ItemView { } } } + + private copyLink(): void { + let link = this.frame instanceof HTMLIFrameElement ? this.frame.contentWindow.location.href : this.frame.getURL(); + navigator.clipboard.writeText(link); + } } interface Action {