MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / hasDocument

Function hasDocument

src/service_worker.ts:20–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18let creating: Promise<void> | null | boolean = null;
19
20async function hasDocument() {
21 const offscreenUrl = chrome.runtime.getURL(OFFSCREEN_DOCUMENT_PATH);
22 const existingContexts = await chrome.runtime.getContexts({
23 contextTypes: [chrome.runtime.ContextType.OFFSCREEN_DOCUMENT],
24 documentUrls: [offscreenUrl],
25 });
26 return existingContexts.length > 0;
27}
28
29async function setupOffscreenDocument() {
30 if (typeof chrome.offscreen?.createDocument !== "function") {

Callers 1

setupOffscreenDocumentFunction · 0.85

Calls 1

getURLMethod · 0.80

Tested by

no test coverage detected