From 67ebd5d8bf3603f9fd7b8006e38221354eba7309 Mon Sep 17 00:00:00 2001 From: Matthew Song Date: Thu, 5 Nov 2026 09:50:14 -0500 Subject: [PATCH 1/2] fix: propagate Chrome script injection errors Return the injection promise through both helpers so getActiveTabDOM can catch asynchronous failures instead of leaving unhandled rejections. --- plugin/js/main.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/plugin/js/main.js b/plugin/js/main.js index 24fa1288..a4598f4b 100644 --- a/plugin/js/main.js +++ b/plugin/js/main.js @@ -245,21 +245,15 @@ var main = (function() { if (util.isFirefox()) { return Firefox.injectContentScript(tabId); } else { - chromeInjectContentScript(tabId); + return chromeInjectContentScript(tabId); } } function chromeInjectContentScript(tabId) { - try { - chrome.scripting.executeScript({ - target: {tabId: tabId}, - files: ["js/ContentScript.js"] - }); - } catch { - if (chrome.runtime.lastError) { - util.log(chrome.runtime.lastError.message); - } - } + return chrome.scripting.executeScript({ + target: {tabId: tabId}, + files: ["js/ContentScript.js"], + }); } function populateControls() { From 5c5f3c32962094ac3e3585d1a1a96852b0f3ff55 Mon Sep 17 00:00:00 2001 From: Matthew Song Date: Thu, 5 Nov 2026 09:47:20 -0500 Subject: [PATCH 2/2] fix: skip injection when the tab URL is unavailable Read the source tab before injecting. When its URL is unavailable, leave WebToEpub open without loading page content. This avoids the missing host permission error on Firefox's New Tab page --- plugin/js/main.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugin/js/main.js b/plugin/js/main.js index a4598f4b..38ebe0e1 100644 --- a/plugin/js/main.js +++ b/plugin/js/main.js @@ -241,7 +241,17 @@ var main = (function() { } } - function injectContentScript(tabId) { + async function injectContentScript(tabId) { + // Checking for firefox here because `browser.*` requires minimum chrome version 148 + const tab = util.isFirefox() + ? await browser.tabs.get(tabId) + : await chrome.tabs.get(tabId); + + const cannotReadUrl = !tab.url; + if (cannotReadUrl) { + return; + } + if (util.isFirefox()) { return Firefox.injectContentScript(tabId); } else {