MCPcopy Create free account
hub / github.com/PaperDebugger/paperdebugger / getBrowserAPI

Function getBrowserAPI

webapp/_webapp/src/intermediate.ts:35–50  ·  view source on GitHub ↗

* Get the browser extension API (chrome or browser). * Returns undefined if not running in an extension context (ISOLATED world).

()

Source from the content-addressed store, hash-verified

33 * Returns undefined if not running in an extension context (ISOLATED world).
34 */
35function getBrowserAPI(): typeof chrome | undefined {
36 try {
37 // @ts-expect-error: browser may not be defined in all environments
38 const candidateBrowser = typeof browser !== "undefined" ? browser : undefined;
39 if (candidateBrowser && typeof candidateBrowser.runtime?.sendMessage === "function") {
40 return candidateBrowser;
41 }
42 const candidateChrome = typeof chrome !== "undefined" ? chrome : undefined;
43 if (candidateChrome && typeof candidateChrome.runtime?.sendMessage === "function") {
44 return candidateChrome;
45 }
46 } catch {
47 // Not in extension context
48 }
49 return undefined;
50}
51
52/**
53 * Check if running in Office Add-in environment

Callers 2

intermediate.tsFile · 0.85
eventHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected