diff --git a/background.js b/background.js index 5b536a5..ca235c8 100644 --- a/background.js +++ b/background.js @@ -228,11 +228,27 @@ async function clearCacheForMessages(idsInput) { browser.messageDisplayAction.setLabel({ label: "Classify" }); } } - if (browser.messageDisplayScripts) { + if (browser.scripting && browser.scripting.messageDisplay) { + try { + const scripts = [ + { + id: "clear-cache-button", + js: [browser.runtime.getURL("resources/clearCacheButton.js")], + }, + { + id: "reason-button", + js: [browser.runtime.getURL("resources/reasonButton.js")], + }, + ]; + await browser.scripting.messageDisplay.registerScripts(scripts); + } catch (e) { + logger.aiLog("failed to register message display script", { level: 'warn' }, e); + } + } else if (browser.messageDisplayScripts) { try { const scripts = [ { js: [browser.runtime.getURL("resources/clearCacheButton.js")] }, - { js: [browser.runtime.getURL("resources/reasonButton.js")] } + { js: [browser.runtime.getURL("resources/reasonButton.js")] }, ]; if (browser.messageDisplayScripts.registerScripts) { await browser.messageDisplayScripts.registerScripts(scripts);