Skip to content

Commit 2bb53b8

Browse files
committed
[frontend] fix url contextmenu hrefs
1 parent 50588fe commit 2bb53b8

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

frontend/src/Tab.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,11 +610,15 @@ function pageContextItems(client: ScramjetClient, tab: Tab, e: MouseEvent) {
610610
},
611611
];
612612
} else if (target && target instanceof view.HTMLAnchorElement) {
613+
let href = Object.getOwnPropertyDescriptor(
614+
HTMLAnchorElement.prototype,
615+
"href"
616+
)!.get!.call(target);
617+
let url = scramjet.decodeUrl(href);
613618
return [
614619
{
615620
label: "Open Link",
616621
action: () => {
617-
const url = scramjet.decodeUrl(target.href);
618622
if (url) {
619623
browser.activetab.pushNavigate(new URL(url));
620624
}
@@ -623,7 +627,6 @@ function pageContextItems(client: ScramjetClient, tab: Tab, e: MouseEvent) {
623627
{
624628
label: "Open Link in New Tab",
625629
action: () => {
626-
const url = scramjet.decodeUrl(target.href);
627630
if (url) {
628631
browser.newTab(new URL(url));
629632
}

frontend/src/components/Shell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { css, type Component } from "dreamland/core";
22
import { browser } from "../Browser";
33
import { forceScreenshot, popTab, pushTab } from "../Browser";
4-
import { takeScreenshotGDM, takeScreenshotSvg } from "../screenshot";
4+
import { takeScreenshotGDM } from "../screenshot";
55

66
export const Shell: Component = function (cx) {
77
pushTab.listen((tab) => {

frontend/src/components/TabStrip.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import type { Tab } from "../Tab";
99
import { setContextMenu } from "./Menu";
1010
import { browser, forceScreenshot } from "../Browser";
1111

12+
const isFirefox =
13+
navigator.userAgent.includes("Gecko/") &&
14+
!navigator.userAgent.includes("Chrome");
15+
1216
export const DragTab: Component<
1317
{
1418
active: boolean;
@@ -90,15 +94,15 @@ export const DragTab: Component<
9094
<span class="title">{use(this.tab.title)}</span>
9195
<span class="hostname">{use(this.tab.url.hostname)}</span>
9296
</div>
93-
{window.chrome ? (
94-
use(this.tab.screenshot).andThen(
95-
<img src={use(this.tab.screenshot)} class="img" />
96-
)
97-
) : (
97+
{isFirefox ? (
9898
<div
9999
style={use`background-image: -moz-element(#tab${this.tab.id})`}
100100
class="img"
101101
></div>
102+
) : (
103+
use(this.tab.screenshot).andThen(
104+
<img src={use(this.tab.screenshot)} class="img" />
105+
)
102106
)}
103107
</div>
104108
<div

0 commit comments

Comments
 (0)