Update warning-page.js

This commit is contained in:
Kenneth Hendricks 2024-11-10 16:20:56 -05:00 committed by GitHub
parent b3e30db0e6
commit 30259fb63d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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.");
}
}
}
});