Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto substandard.blog
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142// The welcome page's address and the one question it exists to ask.//// Chrome offers no manifest field and no API to request a pin — only// `action.getUserSettings()` to read whether the icon is on the toolbar,// which needs no extra permission. Firefox has neither the settings read nor// the same toolbar puzzle piece, so the question is simply answered// "unknown" there. The page asks the user in words, and polls the read to// notice when they have done it.
import { ext } from './platform'
/** The bundled page, opened on first install and from the dev debug menu. */export const WELCOME_PAGE = 'welcome.html'
export function welcomeUrl(): string { return ext.runtime.getURL(WELCOME_PAGE)}
/** How often the open welcome page re-asks whether the icon is pinned. */export const PIN_POLL_MS = 1_000
/** * `unknown` is a real answer, not an error case: the read is advisory, and a * page that cannot get one says nothing rather than telling somebody who has * already pinned the icon to pin it. */export type PinState = 'pinned' | 'unpinned' | 'unknown'
export async function pinState(): Promise<PinState> { // Chrome 91+, so every Chrome above this extension's floor has it — but // Firefox has no counterpart, and a missing API here should cost the page // nothing. if (typeof ext.action?.getUserSettings !== 'function') return 'unknown' try { const settings = await ext.action.getUserSettings() return settings.isOnToolbar ? 'pinned' : 'unpinned' } catch (err) { console.debug('[substandard] could not read the toolbar pin state', err) return 'unknown' }}