(ids)
| 536 | } |
| 537 | |
| 538 | export 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 | |
| 557 | export function checkRemove({ force } = {}) { |
| 558 | const now = Date.now(); |
no test coverage detected