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

Function updateScriptMap

src/background/utils/script.js:273–290  ·  view source on GitHub ↗
(key, val)

Source from the content-addressed store, hash-verified

271
272/** `key` must be already verified to start with S_SCRIPT_PRE */
273export function updateScriptMap(key, val) {
274 if ((key = +key.slice(S_SCRIPT_PRE.length))) {
275 if (val) {
276 const oldScript = scriptMap[key];
277 if (oldScript) {
278 const i1 = aliveScripts.indexOf(oldScript);
279 const i2 = removedScripts.indexOf(oldScript);
280 if (i1 >= 0) aliveScripts[i1] = val;
281 if (i2 >= 0) removedScripts[i2] = val;
282 val[INFERRED] ??= oldScript[INFERRED];
283 }
284 scriptMap[key] = val;
285 } else {
286 delete scriptMap[key];
287 }
288 return true;
289 }
290}

Callers 3

getFunction · 0.90
setFunction · 0.90
removeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected