diff --git a/content/content.js b/content/content.js index 8f13245..4fdb573 100644 --- a/content/content.js +++ b/content/content.js @@ -8,6 +8,11 @@ extractCalls = globalThis.extractCalls; } var UI = globalThis.DSHMEM || null; + if (UI) { + UI.onResetLoops(function () { queue.length = 0; pending.clear(); seenHashes.clear(); pumping = false; if (UI) UI.log('loops reset'); }); + UI.onStop(function () { queue.length = 0; if (UI) UI.log('stopped'); }); + UI.onSaveToken(function (v) { chrome.storage.local.set({ 'dshmem-bridge-token': v }, function () { if (UI) UI.log('token saved, reload page'); }); }); + } if (!SEL) return; if (!BRIDGE) return; if (typeof extractCalls !== "function") return; @@ -171,11 +176,6 @@ if (UI) { UI.setPhase('off'); UI.setConnected(false); UI.log('no token'); } return; } - if (UI) { - UI.onResetLoops(function () { queue.length = 0; pending.clear(); seenHashes.clear(); pumping = false; if (UI) UI.log('loops reset'); }); - UI.onStop(function () { queue.length = 0; if (UI) UI.log('stopped'); }); - UI.onSaveToken(function (v) { chrome.storage.local.set({ 'dshmem-bridge-token': v }, function () { if (UI) UI.log('token saved, reload page'); }); }); - } obs.observe(document.documentElement, { childList: true, subtree: true,