MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / triageScript

Function triageScript

src/injected/content/inject.js:247–267  ·  view source on GitHub ↗
(script)

Source from the content-addressed store, hash-verified

245}
246
247function triageScript(script) {
248 let realm = script[INJECT_INTO];
249 realm = (realm === AUTO && !pageInjectable) || realm === CONTENT
250 ? CONTENT
251 : pageInjectable && PAGE;
252 if (realm) {
253 const lists = realm === CONTENT
254 ? contLists || (contLists = createNullObj())
255 : pageLists || (pageLists = createNullObj());
256 const { gmi, [META_STR]: metaStr, pathMap, [RUN_AT]: runAt } = script;
257 const list = lists[runAt] || (lists[runAt] = []);
258 safePush(list, script);
259 setOwnProp(gmi, 'scriptMetaStr', metaStr[0]
260 || script.code[metaStr[1]]::slice(metaStr[2], metaStr[3]));
261 delete script[META_STR];
262 if (pathMap) bridge.pathMaps[script.id] = pathMap;
263 } else {
264 bridgeIds[script.id] = ID_BAD_REALM;
265 }
266 return realm;
267}
268
269function inject(item, iframeCb) {
270 const { code } = item;

Callers 1

injectScriptsFunction · 0.85

Calls 2

safePushFunction · 0.85
setOwnPropFunction · 0.85

Tested by

no test coverage detected