Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455// The page Chrome opens once, on install (src/background.ts), and that the dev// build's debug menu can open again on demand. Its whole job is the toolbar// pin: the badge is the passive half of what this extension does, and Chrome// keeps a new extension's icon behind the puzzle piece until somebody pins it.
// The generated wordmark, inlined so the theme takes back its baked-in ink —// the same trick the site's hero plays (web/src/pages/index.astro).import wordmark from '../../brand/wordmark.svg?raw'import { ext } from '../lib/platform'import { PIN_POLL_MS, type PinState, pinState } from '../lib/welcome'
/** Elements are declared in welcome.html; a missing id is a packaging bug. */const $ = <T extends HTMLElement>(id: string) => document.getElementById(id) as T
// Our own build output, not remote markup: the file is bundled from brand/.$('wordmark').innerHTML = wordmark
// Read from the manifest rather than baked in at build time, so it is the// version Chrome actually installed — same as the popup header, down to// preferring the dev channel's version_name ("1.4.0+abc1234") when there is// one.const manifest = ext.runtime.getManifest()$('version').textContent = `v${manifest.version_name ?? manifest.version}`
const PIN_LINES: Record<Exclude<PinState, 'unknown'>, string> = { unpinned: 'still waiting for you to pin this extension...', pinned: 'extension pinning confirmed! enjoy your blog posts!',}
async function renderPinState(): Promise<void> { const state = await pinState() const line = $('pin-state') // A browser that will not answer gets no line at all: better to say nothing // than to tell somebody who has already pinned the icon to go and pin it. if (state === 'unknown') { line.hidden = true return } line.textContent = PIN_LINES[state] line.classList.toggle('is-pinned', state === 'pinned') line.hidden = false}
// Chrome fires no event when an icon is pinned, so asking again is the only// way this line can change under the reader while they follow the steps. The// poll is skipped while the tab is in the background, where nobody is looking// — and re-run the moment it comes back, so a tab returned to is never stale.void renderPinState()setInterval(() => { if (document.visibilityState === 'visible') void renderPinState()}, PIN_POLL_MS)document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') void renderPinState()})