From b0e189f6449787fb823e8a58e5d5e74b96acd8f1 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Wed, 18 Jun 2025 22:14:49 -0400 Subject: Update the JShelter extension to 0.21. --- data/extensions/jsr@javascriptrestrictor/popup.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'data/extensions/jsr@javascriptrestrictor/popup.js') diff --git a/data/extensions/jsr@javascriptrestrictor/popup.js b/data/extensions/jsr@javascriptrestrictor/popup.js index a7d7adb..69771c0 100644 --- a/data/extensions/jsr@javascriptrestrictor/popup.js +++ b/data/extensions/jsr@javascriptrestrictor/popup.js @@ -336,21 +336,32 @@ document.getElementById("fpd-switch").addEventListener("change", () => {setTimeo async function getCurrentSite() { if (typeof site !== "undefined") return site; try { + let [tab] = await browser.tabs.query({currentWindow: true, active: true}); // Check whether content scripts are allowed on the current tab: // if an exception is thrown, showing per-site settings is pointless, // because we couldn't operate here anyway - [pageConfiguration = {}] = await browser.tabs.executeScript({code: - `typeof pageConfiguration === "object" && pageConfiguration || {};`}); + if ("executeScript" in browser.tabs) { + [pageConfiguration = {}] = await browser.tabs.executeScript({ + code: `typeof pageConfiguration === "object" && pageConfiguration || {};` + }); + } else { + pageConfiguration = (await browser.scripting.executeScript({ + injectImmediately: true, + func: () => typeof pageConfiguration === "object" && pageConfiguration || {}, + target: {tabId: tab.id}, + }))[0].result; + } - let [tab] = await browser.tabs.query({currentWindow: true, active: true}); hits = await browser.runtime.sendMessage({purpose: 'fpd-fetch-hits', tabId: tab.id}); // Obtain and normalize hostname return site = getEffectiveDomain(tab.url); } catch (e) { - if (e.toString() === "Error: Missing host permission for the tab") { - await async_sleep(200); // recursively call itself, this exception occurs in Firefox during an inactive tab activation (tab page was not reload after the browser start) + if (/^Error: (?:Missing host permissions|Could not establish connection)/.test(e.toString())) { + console.warn("Recoverable timing error during popup startup, retrying in 300ms", e); + await async_sleep(200); return await getCurrentSite(); } + console.error(e); return site = null; } } -- cgit v1.2.3