summaryrefslogtreecommitdiff
path: root/popup/popup.js
diff options
context:
space:
mode:
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(() => {