feat: improve media capture routing and refresh pomeranian icon set
This commit is contained in:
@@ -279,3 +279,56 @@ function watchYoutubeRouteChanges(): void {
|
||||
|
||||
ensureYoutubeOverlay()
|
||||
watchYoutubeRouteChanges()
|
||||
|
||||
let mediaToastRoot: HTMLDivElement | null = null
|
||||
let mediaToastTimer: number | null = null
|
||||
|
||||
function ensureMediaToastRoot(): HTMLDivElement {
|
||||
if (mediaToastRoot) return mediaToastRoot
|
||||
const root = document.createElement('div')
|
||||
root.id = 'gomdown-media-toast'
|
||||
root.style.position = 'fixed'
|
||||
root.style.left = '18px'
|
||||
root.style.bottom = '18px'
|
||||
root.style.zIndex = '2147483647'
|
||||
root.style.maxWidth = '360px'
|
||||
root.style.padding = '10px 12px'
|
||||
root.style.borderRadius = '10px'
|
||||
root.style.border = '1px solid rgba(128, 140, 180, 0.42)'
|
||||
root.style.background = 'rgba(18, 21, 31, 0.95)'
|
||||
root.style.color = '#dce4fa'
|
||||
root.style.fontSize = '12px'
|
||||
root.style.lineHeight = '1.35'
|
||||
root.style.fontFamily = 'ui-sans-serif, -apple-system, BlinkMacSystemFont, Segoe UI, sans-serif'
|
||||
root.style.boxShadow = '0 10px 24px rgba(0, 0, 0, 0.28)'
|
||||
root.style.display = 'none'
|
||||
document.documentElement.appendChild(root)
|
||||
mediaToastRoot = root
|
||||
return root
|
||||
}
|
||||
|
||||
function showMediaCapturedToast(payload: { kind?: string; url?: string; suggestedOut?: string }): void {
|
||||
const root = ensureMediaToastRoot()
|
||||
const kind = String(payload?.kind || 'media').toUpperCase()
|
||||
const out = String(payload?.suggestedOut || '').trim()
|
||||
const shortUrl = String(payload?.url || '').trim().slice(0, 96)
|
||||
root.textContent = out
|
||||
? `캡처됨 [${kind}] ${out}`
|
||||
: `캡처됨 [${kind}] ${shortUrl}${shortUrl.length >= 96 ? '…' : ''}`
|
||||
root.style.display = 'block'
|
||||
if (mediaToastTimer !== null) window.clearTimeout(mediaToastTimer)
|
||||
mediaToastTimer = window.setTimeout(() => {
|
||||
root.style.display = 'none'
|
||||
mediaToastTimer = null
|
||||
}, 2200)
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener((message: any) => {
|
||||
if (message?.type === 'media:captured') {
|
||||
showMediaCapturedToast({
|
||||
kind: message?.kind,
|
||||
url: message?.url,
|
||||
suggestedOut: message?.suggestedOut,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user