mirror of
https://github.com/fmhy/FMHY-SafeGuard.git
synced 2026-03-11 08:55:40 +00:00
Merge 4c05d1f1db into 6b7af7ab9b
This commit is contained in:
commit
28c18c324a
3 changed files with 28 additions and 0 deletions
|
|
@ -486,6 +486,14 @@ async function setupUpdateSchedule() {
|
|||
|
||||
// Event Listeners
|
||||
browserAPI.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
||||
if (message.action === "forceUpdateFilterlist") {
|
||||
fetchFilterLists().then(() => {
|
||||
if (sendResponse) sendResponse({ status: "ok" });
|
||||
}).catch((err) => {
|
||||
if (sendResponse) sendResponse({ status: "error", error: err?.toString() });
|
||||
});
|
||||
return true; // Indicates async response
|
||||
}
|
||||
if (message.action === "checkSiteStatus") {
|
||||
const { url, rootUrl } = message;
|
||||
|
||||
|
|
|
|||
|
|
@ -525,6 +525,9 @@
|
|||
</svg>
|
||||
Next update scheduled for: Checking...
|
||||
</div>
|
||||
<div style="text-align: right; margin-top: 0.75rem;">
|
||||
<button id="forceRefresh" class="btn" style="padding: 0.5rem 1.25rem; font-size: 0.9rem;">Force Update Filterlist</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Appearance -->
|
||||
|
|
|
|||
|
|
@ -1,4 +1,21 @@
|
|||
document.addEventListener("DOMContentLoaded", () => {
|
||||
if (forceRefreshButton) {
|
||||
forceRefreshButton.addEventListener("click", async () => {
|
||||
forceRefreshButton.disabled = true;
|
||||
forceRefreshButton.textContent = "Updating...";
|
||||
try {
|
||||
await browserAPI.runtime.sendMessage({ action: "forceUpdateFilterlist" });
|
||||
showNotification("Filterlist update started.");
|
||||
} catch (error) {
|
||||
showNotification("Failed to start update.", true);
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
forceRefreshButton.disabled = false;
|
||||
forceRefreshButton.textContent = "Force Update Filterlist";
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
// Cross-browser compatibility shim
|
||||
const browserAPI = typeof browser !== "undefined" ? browser : chrome;
|
||||
// Load and display the extension version from manifest.json
|
||||
|
|
|
|||
Loading…
Reference in a new issue