// The one manifest difference between the Chrome and Firefox builds. // // The bundled public/manifest.json stays Chrome's: it carries the `key` that // pins the unpacked extension id (and therefore the OAuth redirect URI) and // the service worker Chrome expects. Firefox MV3 has no service worker, no // `offscreen` API, and its own extension id, so its manifest is transformed // from that one file after Vite copies it into the output directory. // // Pure and dependency-free so the transform can be asserted without running a // build. export const FIREFOX_EXTENSION_ID = 'substandard@permadeath.com' export const FIREFOX_MIN_VERSION = '121.0' /** The manifest Firefox should load, derived from the Chrome one. */ export function firefoxManifest(manifest) { const out = structuredClone(manifest) delete out.key delete out.minimum_chrome_version // Firefox MV3 runs an event page, not a service worker; `type: "module"` // keeps the ES-module output working there. out.background = { scripts: ['background.js'], type: 'module' } out.permissions = (out.permissions ?? []).filter((permission) => permission !== 'offscreen') out.browser_specific_settings = { ...out.browser_specific_settings, gecko: { ...out.browser_specific_settings?.gecko, id: FIREFOX_EXTENSION_ID, strict_min_version: FIREFOX_MIN_VERSION, data_collection_permissions: { required: ['none'] }, }, } return out } /** * Transform a manifest for `target`. Only `firefox` differs; anything else is * the Chrome manifest, returned as a copy. */ export function transformManifest(manifest, target) { if (target === 'firefox') return firefoxManifest(manifest) return structuredClone(manifest) }