summaryrefslogtreecommitdiff
path: root/inject-css.js
blob: 6b3aaf844019a6391a7f4b1a54dde0a002aaaeea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
browser.storage.local.get("transparentZenSettings").then((settings) => {
  if (settings.transparentZenSettings?.enableStyling) {
    browser.storage.local.get("styles").then((data) => {
      const currentUrl = window.location.hostname;
      const cssFileName = Object.keys(data.styles).find((key) =>
        currentUrl.includes(key.replace(".css", ""))
      );
      if (
        cssFileName &&
        settings.transparentZenSettings.websiteSettings?.[
          cssFileName.replace(".css", "")
        ] !== false
      ) {
        let style = document.createElement("style");
        style.textContent = data.styles[cssFileName];
        document.head.appendChild(style);
        console.log(`Injected custom CSS for ${currentUrl}`);
      }
    });
  }
});