Skip to content

Commit

Permalink
Add isActionPopup (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Nov 8, 2024
1 parent 61a13a7 commit 5cb83d8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ export const isSidePanel = once((): boolean =>
isCurrentPathname(getManifest(3)?.['side_panel']?.default_path),
);

export const isActionPopup = once((): boolean => {
// Chrome-only; Firefox uses the whole window…
if (globalThis.outerHeight - globalThis.innerHeight === 14) {
return true;
}

return isCurrentPathname(getManifest(3)?.action?.default_popup ?? getManifest(2)?.browser_action?.default_popup);
});

/** Indicates whether you're in the main dev tools page, the one specified in the extension's `manifest.json` `devtools_page` field. */
export const isMainDevToolsPage = once((): boolean =>
isExtensionContext()
Expand Down Expand Up @@ -133,6 +142,7 @@ const contextChecks = {
background: isBackground,
options: isOptionsPage,
sidePanel: isSidePanel,
actionPopup: isActionPopup,
devTools: isDevTools,
devToolsPage: isDevToolsPage,
offscreenDocument: isOffscreenDocument,
Expand Down

0 comments on commit 5cb83d8

Please sign in to comment.