Add manual 'Force Update Filterlist' button to settings page

This commit is contained in:
Akhil Kumar Achanta 2025-08-31 19:00:03 +00:00
parent b9ca967d71
commit 4c05d1f1db
3 changed files with 28 additions and 0 deletions

View file

@ -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;

View file

@ -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 -->

View file

@ -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