UNPKG

3.56 kBTypeScriptView Raw
1export declare function disableWebextDetectPageCache(): void;
2/** Indicates whether the code is being run on http(s):// pages (it could be in a content script or regular web context) */
3export declare const isWebPage: () => boolean;
4/** Indicates whether you're in extension contexts that have access to the chrome API */
5export declare const isExtensionContext: () => boolean;
6/** Indicates whether you're in a sandboxed page (-extension:// URL protocol, but no chrome.* API access) */
7export declare const isSandboxedPage: () => boolean;
8/** Indicates whether you're in a content script. Note that the MAIN world is not considered a content script. */
9export declare const isContentScript: () => boolean;
10/** Indicates whether you're in a background context */
11export declare const isBackground: () => boolean;
12/** Indicates whether you're in a background page */
13export declare const isBackgroundPage: () => boolean;
14/** Indicates whether you're in a background worker */
15export declare const isBackgroundWorker: () => boolean;
16/** Indicates whether you're in a persistent background page (as opposed to an Event Page or Background Worker, both of which can be unloaded by the browser) */
17export declare const isPersistentBackgroundPage: () => boolean;
18/** Indicates whether you're in an options page. This only works if the current page’s URL matches the one specified in the extension's `manifest.json` */
19export declare const isOptionsPage: () => boolean;
20/** Indicates whether you're in a side panel. This only works if the current page’s URL matches the one specified in the extension's `manifest.json` */
21export declare const isSidePanel: () => boolean;
22export declare const isActionPopup: () => boolean;
23/** Indicates whether you're in the main dev tools page, the one specified in the extension's `manifest.json` `devtools_page` field. */
24export declare const isMainDevToolsPage: () => boolean;
25/** @deprecated Use `isMainDevToolsPage` instead */
26export declare const isDevToolsPage: () => boolean;
27/** Indicates whether you're in the dev tools page. Unlike `isDevToolsPage`, this works in any page that has the `chrome.devTools` API */
28export declare const isDevTools: () => boolean;
29/** Indicates whether you're in a document created via chrome.offscreen */
30export declare const isOffscreenDocument: () => boolean;
31/** Loosely detect Firefox via user agent */
32export declare const isFirefox: () => boolean;
33/** Loosely detect Chrome via user agent (might also include Chromium and forks like Opera) */
34export declare const isChrome: () => boolean;
35/** Loosely detect Safari via user agent */
36export declare const isSafari: () => boolean;
37/** Loosely detect Mobile Safari via user agent */
38export declare const isMobileSafari: () => boolean;
39declare const contextChecks: {
40 readonly contentScript: () => boolean;
41 readonly background: () => boolean;
42 readonly options: () => boolean;
43 readonly sidePanel: () => boolean;
44 readonly actionPopup: () => boolean;
45 readonly devTools: () => boolean;
46 readonly devToolsPage: () => boolean;
47 readonly offscreenDocument: () => boolean;
48 readonly extension: () => boolean;
49 readonly sandbox: () => boolean;
50 readonly web: () => boolean;
51};
52export type ContextName = keyof typeof contextChecks;
53export declare const contextNames: ContextName[];
54/** Returns the first matching context among those defined in `ContextName`, depending on the current context. Returns "unknown" if no match is found. */
55export declare function getContextName(): ContextName | 'unknown';
56export {};