Skip to content

Commit f38100f

Browse files
committed
[frontend] update tab favicon
1 parent 40ff086 commit f38100f

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

frontend/src/browser.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ export class Browser extends StatefulClass {
7676
} else {
7777
tab.title = "New Tab";
7878
}
79+
const favicon = framedoc.querySelector(
80+
"link[rel='icon'], link[rel='shortcut icon']"
81+
);
82+
if (favicon) {
83+
const iconhref = favicon.getAttribute("href");
84+
if (iconhref) {
85+
const rewritten = scramjet.encodeUrl(
86+
new URL(iconhref, frame.client.url)
87+
);
88+
tab.icon = rewritten;
89+
} else {
90+
tab.icon = "/vite.svg";
91+
}
92+
} else {
93+
tab.icon = scramjet.encodeUrl(
94+
new URL("/favicon.ico", frame.client.url)
95+
);
96+
}
7997
});
8098
observer.observe(head, {
8199
childList: true,

frontend/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const scramjet = new ScramjetController({
2222
naiiveRewriter: false,
2323
},
2424
siteFlags: {
25-
"https://www.google.com/.*": {
25+
"https://www.google.com/(search|sorry).*": {
2626
naiiveRewriter: true,
2727
},
2828
"https://worker-playground.glitch.me/.*": {

frontend/src/tabs.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ export class Tab {
168168

169169
width: number;
170170
pos: number;
171+
icon: string;
171172

172173
constructor(title: string, frame: ScramjetFrame) {
173174
return createState({
174175
id: id++,
175176
frame,
176177
title,
177178
url: "puter://blank",
179+
icon: "/vite.svg",
178180
dragoffset: -1,
179181
dragpos: -1,
180182
width: 0,
@@ -361,8 +363,8 @@ export const Tabs: Component<
361363
{use(this.tabs).mapEach((tab) => (
362364
<DragTab
363365
id={tab.id}
364-
title={tab.title}
365-
icon="/vite.svg"
366+
title={use(tab.title)}
367+
icon={use(tab.icon)}
366368
active={use(this.activetab).map((x) => x === tab)}
367369
mousedown={(e) => mouseDown(e, tab)}
368370
click={() => {

0 commit comments

Comments
 (0)