summaryrefslogtreecommitdiff
path: root/popup/popup.js
diff options
context:
space:
mode:
authorsameerasw <[email protected]>2025-05-24 04:51:10 +0530
committersameerasw <[email protected]>2025-05-24 04:51:13 +0530
commit176a8a76245ed60d347d445441e1b75a31f16461 (patch)
treeddc4af7995289839aef00bc69d7b7eb369febbeb /popup/popup.js
parent508d5d551fc3fe07e9f2c36119322b7cba72b290 (diff)
fixed themes applying upon fetching
Diffstat (limited to 'popup/popup.js')
-rw-r--r--popup/popup.js31
1 files changed, 27 insertions, 4 deletions
diff --git a/popup/popup.js b/popup/popup.js
index 9b2cd29..a35a8cd 100644
--- a/popup/popup.js
+++ b/popup/popup.js
@@ -687,6 +687,17 @@ new (class ExtensionPopup {
console.log("Fetching styles from:", repositoryUrl);
+ // Store existing site-specific settings before fetching new styles
+ const allStorageData = await browser.storage.local.get(null);
+ const existingSiteSettings = {};
+
+ // Identify and keep all site-specific settings
+ for (const [key, value] of Object.entries(allStorageData)) {
+ if (key.startsWith(this.BROWSER_STORAGE_KEY + ".")) {
+ existingSiteSettings[key] = value;
+ }
+ }
+
const response = await fetch(repositoryUrl, {
headers: {
"Cache-Control": "no-cache",
@@ -731,12 +742,24 @@ new (class ExtensionPopup {
// Update labels
this.updateModeLabels();
} else {
- // Just update the lastFetchedTime
- await browser.storage.local.set({ lastFetchedTime: Date.now() });
+ // Just update the lastFetchedTime while preserving other settings
+ const updatedSettings = {
+ ...settingsData[this.BROWSER_STORAGE_KEY],
+ lastFetchedTime: Date.now(),
+ };
+ await browser.storage.local.set({
+ [this.BROWSER_STORAGE_KEY]: updatedSettings,
+ });
}
- this.loadCurrentSiteFeatures();
- this.updateActiveTabStyling();
+ // Reload the current site features
+ await this.loadCurrentSiteFeatures();
+
+ // Notify background script to immediately reapply CSS to active tabs
+ browser.runtime.sendMessage({
+ action: "reapplyStylesAfterFetch",
+ preserveSettings: true,
+ });
this.refetchCSSButton.textContent = "Done!";
setTimeout(() => {