summaryrefslogtreecommitdiff
path: root/background.js
diff options
context:
space:
mode:
authorsameerasw <[email protected]>2025-02-25 13:58:42 +0530
committersameerasw <[email protected]>2025-02-25 13:58:42 +0530
commite36e4ce96399db97f80c8833fa6ef2982a249e51 (patch)
treeaad6d10a8adb6a06b8ef6766735942e8c1a15d6c /background.js
parent82f7640e9908c0503a879244d2c178b0dd2e6b62 (diff)
initial zeninternet commit - remote css loading from repository - for github.com only
Diffstat (limited to 'background.js')
-rw-r--r--background.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/background.js b/background.js
new file mode 100644
index 0000000..3c25ff3
--- /dev/null
+++ b/background.js
@@ -0,0 +1,29 @@
+const CSS_URL =
+ "https://sameerasw.github.io/my-internet/github.com.css";
+
+async function updateCSS() {
+ try {
+ let response = await fetch(CSS_URL, {
+ headers: {
+ 'Cache-Control': 'no-cache'
+ }
+ });
+ if (!response.ok) throw new Error("Failed to fetch CSS");
+ let cssText = await response.text();
+ await browser.storage.local.set({ githubCSS: cssText });
+ await browser.storage.sync.set({ githubCSS: cssText });
+ console.log("Updated GitHub CSS from remote source." + cssText);
+ } catch (error) {
+ console.error("Error fetching CSS:", error);
+ }
+}
+
+// Fetch CSS on startup and then every hour
+updateCSS();
+
+// Listen for messages to restart the background script
+browser.runtime.onMessage.addListener((message) => {
+ if (message.action === "restartBackground") {
+ browser.runtime.reload();
+ }
+}); \ No newline at end of file