From 342a7f93c774c5b2790c9fab7b989c0d8675913c Mon Sep 17 00:00:00 2001 From: Lucie Bader <167515375+Lucie-Bdr@users.noreply.github.com> Date: Sun, 16 Feb 2025 17:04:23 +0100 Subject: [PATCH] Correction beug onglets --- src/background/background.js | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/background/background.js b/src/background/background.js index bb100c0..5567a89 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -132,12 +132,28 @@ worker.onmessage = (event) => { if (event.data.type === "pyodide-simplemma" && event.data.status === "success") { browser.tabs.query({}).then((tabs) => { tabs.forEach((tab) => { - browser.tabs.sendMessage(tab.id, { command: "pyodide-simplemma-ready" }) - .catch((error) => console.warn(`[Background] Impossible d'envoyer un message à l'onglet ${tab.id} : ${error}`)); + if (!tab.url || (!tab.url.startsWith("https://") && (!tab.url.startsWith("https://")))) { + return; + } + if (tab.url.includes("sidebar.html")) { + return; + } + + try { + let response = browser.tabs.sendMessage(tab.id, { command: "pyodide-simplemma-ready" }) + if (response && typeof response.then === "function") { + response.then(() => { + }).catch((error) => { + log("[Background] Impossible d'envoyer un message à l'onglet ${tab.id} : ${error}"); + }); + } + } catch (error) { + log("[Background] Erreur lors de l'envoi d'un message à l'onglet ${tab.id} : ${error}"); + } }); - }); + }) } -}; +} // ───────────────────────────────────────────────────────────────────────────── // Fonctions d'authentification & de redirection -- GitLab