I am working on a library which needs to be called & executed in the background script only. How to check if the library is being executed in background script only ?
- So, something like this :..
const isBackgroundScript = checkForBackgroundScript();
if (!isBackgroundScript) {
throw new Error(`xyz function can only be called from background script`);
}
ManifestV3 background script is a service worker:
ManifestV2: