diff --git a/src/actors/ContextMenu.types.ts b/src/actors/ContextMenu.types.ts
index b4ce07b..ef9a516 100644
--- a/src/actors/ContextMenu.types.ts
+++ b/src/actors/ContextMenu.types.ts
@@ -13,4 +13,5 @@ export interface ContextMenuInfo {
}
textSelection?: string
+ href?: string
}
diff --git a/src/actors/ContextMenuChild.ts b/src/actors/ContextMenuChild.ts
index a5616f7..269498c 100644
--- a/src/actors/ContextMenuChild.ts
+++ b/src/actors/ContextMenuChild.ts
@@ -11,6 +11,16 @@ const lazy = lazyESModuleGetters({
})
export class ContextMenuChild extends JSWindowActorChild {
+ getHrefIfExists(target: Node): string | undefined {
+ if ((target as HTMLAnchorElement).href) {
+ return (target as HTMLAnchorElement).href
+ }
+
+ if (target.parentElement) {
+ return this.getHrefIfExists(target.parentElement)
+ }
+ }
+
handleEvent(event: MouseEvent & { inputSource: number }) {
const data: {
position: ContextMenuInfo['position']
@@ -29,6 +39,8 @@ export class ContextMenuChild extends JSWindowActorChild {
data.textSelection = selectionInfo.fullText
}
+ if (event.target) data.href = this.getHrefIfExists(event.target as Node)
+
this.sendAsyncMessage('contextmenu', data satisfies ContextMenuInfo)
}
}
diff --git a/src/content/browser/components/contextMenus/BrowserContextMenu.svelte b/src/content/browser/components/contextMenus/BrowserContextMenu.svelte
index 385bb3a..7bac34c 100644
--- a/src/content/browser/components/contextMenus/BrowserContextMenu.svelte
+++ b/src/content/browser/components/contextMenus/BrowserContextMenu.svelte
@@ -3,14 +3,38 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->