Skip to content

Commit

Permalink
Add isSandboxedPage (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Jul 30, 2024
1 parent a74a706 commit 5a6adef
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 @@ -45,6 +45,9 @@ export const isExtensionContext = once((): boolean =>
typeof globalThis.chrome?.extension === 'object',
);

/** Indicates whether the code is being run in a sandboxed page (-extension:// URL protocol, but no chrome.* API access) */
export const isSandboxedPage = once((): boolean => location.protocol.endsWith('-extension:') && !isExtensionContext());

/** Indicates whether the code is being run in a content script */
export const isContentScript = once((): boolean =>
isExtensionContext() && isWebPage(),
Expand Down

0 comments on commit 5a6adef

Please sign in to comment.