diff options
author | sameerasw <[email protected]> | 2025-02-26 00:16:29 +0530 |
---|---|---|
committer | sameerasw <[email protected]> | 2025-02-26 00:16:29 +0530 |
commit | 2e79ce31b430b256fcdda0dd55a7ef1fdca5426a (patch) | |
tree | 43412b440ec5dc6c48b101fe8e6a6e922c20fd47 /popup | |
parent | 7d297b23975ede17fa465ebf0139ee1d274837f8 (diff) |
switched from css fetching to the styles.json
Diffstat (limited to 'popup')
-rw-r--r-- | popup/popup.js | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/popup/popup.js b/popup/popup.js index f9dacfd..f743179 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -57,9 +57,6 @@ new (class ExtensionPopup { browser.storage.local.set({ [this.BROWSER_STORAGE_KEY]: this.browserStorageSettings, }); - browser.storage.sync.set({ - [this.BROWSER_STORAGE_KEY]: this.browserStorageSettings, - }); console.info("Settings saved", this.browserStorageSettings); } @@ -93,38 +90,28 @@ new (class ExtensionPopup { async refetchCSS() { this.refetchCSSButton.textContent = "Fetching..."; try { - const response = await fetch("/mapper.json", { - headers: { - "Cache-Control": "no-cache", - }, - }); - if (!response.ok) throw new Error("Failed to fetch mapper.json"); - const mapping = await response.json(); - for (const [site, cssFileName] of Object.entries(mapping)) { - const cssResponse = await fetch( - `https://sameerasw.github.io/my-internet/${cssFileName}`, - { - headers: { - "Cache-Control": "no-cache", - }, - } - ); - if (!cssResponse.ok) throw new Error(`Failed to fetch CSS for ${site}`); - const cssText = await cssResponse.text(); - await browser.storage.local.set({ [cssFileName]: cssText }); - await browser.storage.sync.set({ [cssFileName]: cssText }); - } + const response = await fetch( + "https://sameerasw.github.io/my-internet/styles.json", + { + headers: { + "Cache-Control": "no-cache", + }, + } + ); + if (!response.ok) throw new Error("Failed to fetch styles.json"); + const styles = await response.json(); + await browser.storage.local.set({ styles }); this.refetchCSSButton.textContent = "Done!"; setTimeout(() => { this.refetchCSSButton.textContent = "Refetch latest styles"; }, 2000); - console.info("All CSS files refetched and updated from GitHub."); + console.info("All styles 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); + console.error("Error refetching styles:", error); } } |