summaryrefslogtreecommitdiff
path: root/background.js
blob: 3c25ff31778516a6d56acec0a1153ac1c03cba4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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();
  }
});