summaryrefslogtreecommitdiff
path: root/popup
diff options
context:
space:
mode:
authorsameerasw <[email protected]>2025-02-25 15:46:34 +0530
committersameerasw <[email protected]>2025-02-25 15:46:34 +0530
commit3e8b7b3cfc273ebe348b4c40d869a456db895c7c (patch)
treec53af64bb4ed9c895922c31d61a5743b2d16e288 /popup
parent36cb8d72865b1ab5cbcb008f939d916dfd1d206d (diff)
no background scripts
Diffstat (limited to 'popup')
-rw-r--r--popup/popup.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/popup/popup.js b/popup/popup.js
index 494f170..6a28e31 100644
--- a/popup/popup.js
+++ b/popup/popup.js
@@ -2,6 +2,7 @@ new (class ExtensionPopup {
BROWSER_STORAGE_KEY = "transparentZenSettings";
browserStorageSettings = {};
enableStylingSwitch = document.getElementById("enable-styling");
+ refetchCSSButton = document.getElementById("refetch-css");
constructor() {
this.loadSettings().then((settings) => {
@@ -11,9 +12,7 @@ new (class ExtensionPopup {
this.bindEvents();
}
});
- document
- .getElementById("refetch-css")
- .addEventListener("click", this.refetchCSS.bind(this));
+ this.refetchCSSButton.addEventListener("click", this.refetchCSS.bind(this));
document
.getElementById("restart-background")
.addEventListener("click", this.restartBackground);
@@ -48,11 +47,11 @@ new (class ExtensionPopup {
browser.storage.sync.set({
[this.BROWSER_STORAGE_KEY]: this.browserStorageSettings,
});
- browser.runtime.sendMessage({ action: "updateSettings" });
console.info("Settings saved", this.browserStorageSettings);
}
async refetchCSS() {
+ this.refetchCSSButton.textContent = "Fetching...";
try {
const response = await fetch("/mapper.json", {
headers: {
@@ -75,15 +74,22 @@ new (class ExtensionPopup {
await browser.storage.local.set({ [cssFileName]: cssText });
await browser.storage.sync.set({ [cssFileName]: cssText });
}
- browser.runtime.sendMessage({ action: "updateCSS" });
+ this.refetchCSSButton.textContent = "Done!";
+ setTimeout(() => {
+ this.refetchCSSButton.textContent = "Refetch latest styles";
+ }, 2000);
console.info("All CSS files refetched and updated from GitHub.");
} catch (error) {
+ this.refetchCSSButton.textContent = "Error!";
+ setTimeout(() => {
+ this.refetchCSSButton.textContent = "Refetch latest styles";
+ }, 2000);
console.error("Error refetching CSS:", error);
}
}
async restartBackground() {
- browser.runtime.sendMessage({ action: "restartBackground" });
+ browser.runtime.reload();
console.info("Background script restart requested.");
}
})();