diff --git a/src/pub/warning-page.js b/src/pub/warning-page.js index fe67773..973f028 100644 --- a/src/pub/warning-page.js +++ b/src/pub/warning-page.js @@ -27,16 +27,21 @@ document.addEventListener("DOMContentLoaded", () => { `Sending approveSite message for tab ${currentTab.id} and URL ${unsafeUrl}` ); - // Send approval message to the background script - await browserAPI.runtime.sendMessage({ + // Approve the site and wait for confirmation from the background script + const response = await browserAPI.runtime.sendMessage({ action: "approveSite", tabId: currentTab.id, url: unsafeUrl, }); - console.log("Approval stored, navigating to the unsafe URL..."); - // Redirect to the approved unsafe URL - await browserAPI.tabs.update(currentTab.id, { url: unsafeUrl }); + if (response && response.status === "approved") { + console.log("Approval confirmed, navigating to the unsafe URL..."); + + // Redirect to the approved unsafe URL + await browserAPI.tabs.update(currentTab.id, { url: unsafeUrl }); + } else { + console.error("Approval failed or no response from background."); + } } } });