From 30259fb63ddb3c24b276595f27934967828a1f4c Mon Sep 17 00:00:00 2001 From: Kenneth Hendricks <50819541+kenhendricks00@users.noreply.github.com> Date: Sun, 10 Nov 2024 16:20:56 -0500 Subject: [PATCH] Update warning-page.js --- src/pub/warning-page.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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."); + } } } });