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

Function undoImport

src/background/utils/storage-cache.js:226–247  ·  view source on GitHub ↗
(port)

Source from the content-addressed store, hash-verified

224}
225
226async function undoImport(port) {
227 let drop;
228 let old;
229 port.onDisconnect.addListener(() => {
230 ignoreChromeErrors();
231 drop = true;
232 });
233 port.onMessage.addListener(async () => {
234 valuesToFlush = {};
235 const cur = await cachedStorageApi.get();
236 const toRemove = Object.keys(cur).filter(k => !(k in old));
237 const delay = Math.max(50, Math.min(500, performance.getEntries()[0]?.duration || 200));
238 undoing = true;
239 if (toRemove.length) await cachedStorageApi.remove(toRemove);
240 await cachedStorageApi.set(old);
241 port.postMessage(true);
242 await sendCmd('Reload', delay);
243 location.reload();
244 });
245 old = await api.get();
246 if (!drop) port.postMessage(true);
247}

Callers 1

storage-cache.jsFile · 0.85

Calls 6

ignoreChromeErrorsFunction · 0.90
sendCmdFunction · 0.90
filterMethod · 0.80
removeMethod · 0.80
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected