Files
PassKeeper/extension/shared/browser-polyfill.js
T

20 lines
823 B
JavaScript

/**
* shared/browser-polyfill.js
*
* Minimal shim so content scripts and bridge.js can use `chrome.*` on Firefox.
* Firefox exposes the WebExtensions API as `browser.*` (promise-based).
* Chrome exposes it as `chrome.*` (callback-based, with Promise wrappers in MV3).
*
* This shim only aliases `browser` → `chrome` when `chrome` is not defined,
* which is sufficient for the subset of APIs used by PassKeeper content scripts
* (chrome.runtime, chrome.storage.session/local, chrome.storage.onChanged).
*
* For full cross-browser compatibility, replace with the official
* Mozilla WebExtension browser-polyfill:
* https://github.com/mozilla/webextension-polyfill
*/
if (typeof chrome === 'undefined' && typeof browser !== 'undefined') {
// eslint-disable-next-line no-global-assign
chrome = browser;
}