MCPcopy Create free account
hub / github.com/andreadev-it/stacking-contexts-inspector / getScriptConnection

Function getScriptConnection

src/scripts/background.js:94–106  ·  view source on GitHub ↗

* Get a script connection, and if there is no script associated with the tab, it injects it. * * @param {string} scriptId * @param {number} tabId * @param {boolean} analysePage Only when the scriptId is 'content', it forces a page analysis before returning the connection. * @returns {Promise<

(scriptId, tabId, injectOnFail=true)

Source from the content-addressed store, hash-verified

92 * @returns {Promise<Connection>} The connection to the content script
93 */
94async function getScriptConnection(scriptId, tabId, injectOnFail=true) {
95
96 if (!bgHandler.hasConnectedScript(scriptId, tabId)) {
97 // Not returning anything if there is no script attached and we don't want to automatically inject the content script
98 if (!injectOnFail) return undefined;
99
100 await injectScript(tabId);
101 }
102
103 let conn = await bgHandler.getScriptConnection(scriptId, tabId);
104
105 if (conn) return conn;
106}
107
108/**
109 * Analyzes the page related to a specific tab id and returns a JSON description of the stacking contexts.

Callers 12

notifySettingsChangedFunction · 0.85
analysePageFunction · 0.85
highlightContextFunction · 0.85
undoHighlightContextFunction · 0.85
scrollToContextFunction · 0.85
getPathFromContextFunction · 0.85
getPageFramesSourcesFunction · 0.85
startDOMObserverFunction · 0.85
stopDOMObserverFunction · 0.85
sendDOMChangedWarningFunction · 0.85

Calls 1

injectScriptFunction · 0.85

Tested by

no test coverage detected