diff --git a/src/background.ts b/src/background.ts index 24dcf31..8446be8 100644 --- a/src/background.ts +++ b/src/background.ts @@ -28,9 +28,11 @@ chrome.webNavigation.onCommitted.addListener( tabId: details.tabId, frameIds: [details.frameId], } - void chrome.scripting.insertCSS({ + chrome.scripting.insertCSS({ css: cssToInject, target: target, + }).catch((error) => { + console.info("OpenBlur Could not inject CSS into tab %d", details.tabId, error) }) } } @@ -46,9 +48,11 @@ chrome.runtime.onMessage.addListener( if (sender.frameId !== undefined) { target.frameIds = [sender.frameId] } - void chrome.scripting.removeCSS({ + chrome.scripting.removeCSS({ css: cssToInject, target: target, + }).catch((error) => { + console.info("OpenBlur Could not remove CSS from tab %d", target.tabId, error) }) } if (request.mode) { diff --git a/src/popup.ts b/src/popup.ts index a9158be..644df4b 100644 --- a/src/popup.ts +++ b/src/popup.ts @@ -22,8 +22,14 @@ chrome.storage.sync.get(null, (data) => { // Send message to content script in all tabs const tabs = await chrome.tabs.query({}) for (const tab of tabs) { - console.debug("OpenBlur Sending message to tab id %d, url %s", tab.id, tab.url) - void chrome.tabs.sendMessage(tab.id!, {literals}) + console.debug("OpenBlur Sending literals message to tab id %d, title '%s' url %s", tab.id, tab.title, tab.url) + chrome.tabs.sendMessage(tab.id!, {literals}) + .catch((error) => { + // We ignore tabs without a proper URL, like chrome://extensions/ + if (tab.url) { + console.info("OpenBlur Could not send message to tab with title '%s' and url %s. Was OpenBlur just installed?", tab.title, tab.url, error) + } + }) } } }) @@ -38,8 +44,14 @@ checkbox.addEventListener("change", async (event) => { // Send message to content script in all tabs const tabs = await chrome.tabs.query({}) for (const tab of tabs) { - console.debug("OpenBlur Sending message to tab id %d, url %s", tab.id, tab.url) - void chrome.tabs.sendMessage(tab.id!, {mode: mode}) + console.debug("OpenBlur Sending mode message to tab id %d, title '%s' url %s", tab.id, tab.title, tab.url) + chrome.tabs.sendMessage(tab.id!, {mode: mode}) + .catch((error) => { + // We ignore tabs without a proper URL, like chrome://extensions/ + if (tab.url) { + console.info("OpenBlur Could not send message to tab with title '%s' and url %s. Was OpenBlur just installed?", tab.title, tab.url, error) + } + }) } } })