diff --git a/src/content/index.js b/src/content/index.js index dab2449..93d2171 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -9,6 +9,7 @@ const init = async () => { await initSettings(); document.addEventListener("mouseup", handleMouseUp); document.addEventListener("keydown", handleKeyDown); + window.addEventListener("unload", onUnload, { once: true }); browser.storage.onChanged.addListener(handleSettingsChange); browser.runtime.onMessage.addListener(handleMessage); overWriteLogLevel(); @@ -132,6 +133,10 @@ const handleKeyDown = e => { } }; +const onUnload = () => { + browser.storage.onChanged.removeListener(handleSettingsChange); +}; + let isEnabled = true; const handleMessage = async request => { const empty = new Promise(resolve => {