From dd8f3054ee06122cd7a7daca009d8bbbc7e882f5 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 1 Jun 2022 15:22:33 +0200 Subject: [PATCH] Added "open in browser" button Closes #32 --- src/frame.ts | 5 ++--- src/view.ts | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/frame.ts b/src/frame.ts index 098ebc0..97b1a21 100644 --- a/src/frame.ts +++ b/src/frame.ts @@ -89,8 +89,7 @@ export class CustomFrame { } } - public copyLink(): void { - let link = this.frame instanceof HTMLIFrameElement ? this.frame.contentWindow.location.href : this.frame.getURL(); - navigator.clipboard.writeText(link); + public getCurrentUrl(): string { + return this.frame instanceof HTMLIFrameElement ? this.frame.contentWindow.location.href : this.frame.getURL(); } } \ No newline at end of file diff --git a/src/view.ts b/src/view.ts index 79ad9b8..e85773d 100644 --- a/src/view.ts +++ b/src/view.ts @@ -16,7 +16,11 @@ export class CustomFrameView extends ItemView { }, { name: "Copy link", icon: "link", - action: v => v.frame.copyLink() + action: v => navigator.clipboard.writeText(v.frame.getCurrentUrl()) + }, { + name: "Open in browser", + icon: "globe", + action: v => open(v.frame.getCurrentUrl()) }, { name: "Refresh", icon: "refresh-cw",