mirror of
https://github.com/fmhy/FMHY-SafeGuard.git
synced 2026-03-11 08:55:40 +00:00
Update index.js
Updated icons to display properly
This commit is contained in:
parent
ad0f353d04
commit
b3e30db0e6
1 changed files with 19 additions and 1 deletions
|
|
@ -51,6 +51,9 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||
return; // Skip further processing since it's an internal page
|
||||
}
|
||||
|
||||
// Extract the root URL for display
|
||||
const rootUrl = extractRootUrl(currentUrl);
|
||||
|
||||
// Send a message to the background script to check the site's status
|
||||
const response = await browserAPI.runtime.sendMessage({
|
||||
action: "checkSiteStatus",
|
||||
|
|
@ -63,13 +66,28 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||
);
|
||||
}
|
||||
|
||||
handleStatusUpdate(response.status, currentUrl);
|
||||
handleStatusUpdate(response.status, rootUrl);
|
||||
} catch (error) {
|
||||
console.error("Error while checking site status:", error);
|
||||
errorMessage.textContent = `Error: ${error.message}`;
|
||||
updateUI("error", "An error occurred while retrieving the site status.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the root URL from a full URL.
|
||||
* @param {string} url - The full URL to extract the root from.
|
||||
* @returns {string} - The root URL.
|
||||
*/
|
||||
function extractRootUrl(url) {
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
return `${urlObj.protocol}//${urlObj.hostname}`;
|
||||
} catch (error) {
|
||||
console.warn("Failed to extract root URL:", error);
|
||||
return url; // Fallback to full URL if extraction fails
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the UI based on the site status
|
||||
* @param {string} status - The status of the site (e.g., "safe", "unsafe")
|
||||
|
|
|
|||
Loading…
Reference in a new issue