Add manifest.firefox.json for Firefox MV3 (gecko ID, background scripts instead of service_worker, options_ui). Introduce browser-polyfill.js shim so all modules use whichever API is available (browser.* or chrome.*). Add build.sh to target chrome, firefox, or both. https://claude.ai/code/session_01Dvgwe7XMoSxnWXkih8p1Cw
21 lines
508 B
JavaScript
21 lines
508 B
JavaScript
/**
|
|
* Minimal browser API compatibility layer.
|
|
*
|
|
* Firefox exposes `browser.*` (Promise-based) and polyfills `chrome.*`.
|
|
* Chrome only has `chrome.*` (callback-based, but storage/runtime are
|
|
* Promise-based in MV3). This normalizes to whichever is available.
|
|
*/
|
|
|
|
const api =
|
|
typeof browser !== 'undefined' && browser.runtime
|
|
? browser
|
|
: typeof chrome !== 'undefined'
|
|
? chrome
|
|
: null;
|
|
|
|
if (!api) {
|
|
console.error('[Silent Send] No WebExtension API found');
|
|
}
|
|
|
|
export default api;
|