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

Function removeScripts

src/background/utils/db.js:538–555  ·  view source on GitHub ↗
(ids)

Source from the content-addressed store, hash-verified

536}
537
538export async function removeScripts(ids) {
539 const idsToRemove = [];
540 // Only those marked as removed can be removed permanently
541 const newLen = 1 + removedScripts.reduce((iAlive, script, i) => {
542 const id = getPropsId(script);
543 if (ids.includes(id)) {
544 idsToRemove.push(S_CODE_PRE + id, S_SCRIPT_PRE + id, S_VALUE_PRE + id);
545 delete scriptMap[id];
546 } else if (++iAlive < i) removedScripts[iAlive] = script;
547 return iAlive;
548 }, -1);
549 if (removedScripts.length !== newLen) {
550 removedScripts.length = newLen; // live scripts were moved to the beginning
551 await storage.api.remove(idsToRemove);
552 vacuum();
553 return sendCmd('RemoveScripts', ids);
554 }
555}
556
557export function checkRemove({ force } = {}) {
558 const now = Date.now();

Callers 1

checkRemoveFunction · 0.85

Calls 4

sendCmdFunction · 0.90
getPropsIdFunction · 0.85
vacuumFunction · 0.85
removeMethod · 0.80

Tested by

no test coverage detected