summaryrefslogtreecommitdiff
path: root/background.js
diff options
context:
space:
mode:
authorsameerasw <[email protected]>2025-05-06 18:32:32 +0530
committersameerasw <[email protected]>2025-05-06 18:32:32 +0530
commita3c2e7fd7a7c8d22b9defc5c09caed40ccedafb9 (patch)
tree3d294ea8d7b9fa7a2617d9ab5958eba80b8deb07 /background.js
parentf3f4079aabc93d2c92d943b95d0f2360ed6b1b79 (diff)
Implemented custom styles repository feature
Diffstat (limited to 'background.js')
-rw-r--r--background.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/background.js b/background.js
index 60fd68e..19ef0fe 100644
--- a/background.js
+++ b/background.js
@@ -818,11 +818,20 @@ function stopAutoUpdate() {
async function refetchCSS() {
if (logging) console.log("refetchCSS called");
try {
- 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");
+ // Get the repository URL from storage or use the default one
+ const DEFAULT_REPOSITORY_URL =
+ "https://sameerasw.github.io/my-internet/styles.json";
+ const repoUrlData = await browser.storage.local.get("stylesRepositoryUrl");
+ const repositoryUrl =
+ repoUrlData.stylesRepositoryUrl || DEFAULT_REPOSITORY_URL;
+
+ console.log("Background: Fetching styles from:", repositoryUrl);
+
+ const response = await fetch(repositoryUrl, {
+ headers: { "Cache-Control": "no-cache" },
+ });
+ if (!response.ok)
+ throw new Error(`Failed to fetch styles (Status: ${response.status})`);
const styles = await response.json();
await browser.storage.local.set({ styles });
@@ -849,7 +858,7 @@ async function refetchCSS() {
await browser.storage.local.set({ lastFetchedTime: Date.now() });
}
- console.info("All styles refetched and updated from GitHub.");
+ console.info(`All styles refetched and updated from ${repositoryUrl}`);
// Preload the new styles
preloadStyles();