Skip to content

Commit eab2930

Browse files
committed
Update util.ts
1 parent 6d807d4 commit eab2930

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/util.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function getArchivedConversations(archiveDir: string): Promise<Map<
2323
const map = new Map<string, string>()
2424

2525
for (const file of files) {
26-
const match = file.match(/^(?<id>[^-]+) - .+\.html$/)
26+
const match = file.match(/^(?<id>[^-]+) - .*\.html$/)
2727
if (match) map.set(match.groups?.["id"] as string, file)
2828
}
2929

@@ -70,11 +70,19 @@ export async function archiveConversation(browser: Browser, id: string) {
7070
document.getElementsByClassName("share-landing-page_footer")[0]?.remove()
7171

7272
// Copy and flag buttons
73-
const matButtons = document.querySelectorAll("[mat-icon-button]")
74-
while (matButtons.length > 0) matButtons[0]!.remove()
75-
// Expand button for reasoning steps
76-
const matIcons = document.querySelectorAll("mat-icon")
77-
while (matIcons.length > 0) matIcons[0]!.remove()
73+
for (const matButton of document.querySelectorAll("[mat-icon-button]")) matButton.remove()
74+
75+
// Replace mat-icon with equivalent SVGs, as the icon font is heavy
76+
// e.g. expand button for reasoning steps, Deep Research steps
77+
const matIcons = document.getElementsByTagName("mat-icon")
78+
while (matIcons.length > 0) {
79+
const matIcon = matIcons[0]!
80+
const iconName = matIcon.getAttribute("fonticon")
81+
const img = document.createElement("img")
82+
img.src = `https://fonts.gstatic.com/s/i/short-term/release/materialsymbolsoutlined/${iconName}/default/${getComputedStyle(matIcon).fontSize}.svg`
83+
matIcon.insertAdjacentElement("afterend", img)
84+
matIcon.remove()
85+
}
7886

7987
// Disclaimer
8088
document.getElementsByClassName("share-viewer_footer_disclaimer")[0]?.remove()

0 commit comments

Comments
 (0)