Skip to content

Commit

Permalink
Add isPersistentBackgroundPage (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Dec 29, 2023
1 parent 5fab945 commit a963d20
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ export const isBackgroundWorker = once(
(): boolean => isCurrentPathname(getManifest(3)?.background?.service_worker),
);

/** Indicates whether the code is being run in a persistent background page (as opposed to an Event Page or Background Worker, both of which can be unloaded by the browser) */
export const isPersistentBackgroundPage = (): boolean => isBackgroundPage() && getManifest(2)?.background?.persistent !== false;

/** Indicates whether the code is being run in an options page. This only works if the current page’s URL matches the one specified in the extension's `manifest.json` */
export const isOptionsPage = once((): boolean => {
const path = getManifest()?.options_ui?.page;
Expand Down

0 comments on commit a963d20

Please sign in to comment.