Skip to content

Commit

Permalink
fix: remove unsplash related workarounds
Browse files Browse the repository at this point in the history
unsplash image url won't be rendered by chatgpt anymore
  • Loading branch information
pionxzh committed Dec 21, 2023
1 parent c9c7689 commit ba6f2f7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
26 changes: 0 additions & 26 deletions src/main.tsx
Expand Up @@ -61,32 +61,6 @@ function main() {
})
}

// dirty fix for unstable image url from unsplash
const imageMap = new Map<string, string>()

sentinel.on('img', (img: HTMLImageElement) => {
const src = img.src
if (src.startsWith('https://source.unsplash.com/')) {
if (imageMap.has(src)) {
img.src = imageMap.get(src)!
return
}

const xhr = new XMLHttpRequest()
xhr.open('HEAD', src, true)
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
const finalUrl = xhr.responseURL
img.src = finalUrl
// @ts-expect-error private field
img.originalSrc = src
imageMap.set(src, finalUrl)
}
}
xhr.send()
}
})

/** Insert timestamp to the bottom right of each message */
let chatId = ''
sentinel.on('main .group', async () => {
Expand Down
9 changes: 0 additions & 9 deletions src/style.css
@@ -1,12 +1,3 @@
img[src*="https://source.unsplash.com/"] {
visibility: hidden;
}

/* hide the flickering */
p > img[src*="https://images.unsplash.com/"] {
animation: fadeIn .3s;
}

span[data-time-format] {
display: none;
}
Expand Down

0 comments on commit ba6f2f7

Please sign in to comment.