diff options
Diffstat (limited to 'inject-css.js')
| -rw-r--r-- | inject-css.js | 29 | 
1 files changed, 22 insertions, 7 deletions
| diff --git a/inject-css.js b/inject-css.js index c54c80e..c889e18 100644 --- a/inject-css.js +++ b/inject-css.js @@ -1,8 +1,23 @@ -browser.storage.sync.get("githubCSS").then((data) => { -    if (data.githubCSS) { -        let style = document.createElement("style"); -        style.textContent = data.githubCSS; -        document.head.appendChild(style); -        console.log("Injected custom GitHub CSS."); -    } +browser.storage.sync.get("transparentZenSettings").then((settings) => { +  if (settings.transparentZenSettings?.enableStyling) { +    fetch(browser.runtime.getURL("mapper.json")) +      .then((response) => response.json()) +      .then((mapping) => { +        const currentUrl = window.location.hostname; +        const matchedKey = Object.keys(mapping).find((key) => +          currentUrl.includes(key) +        ); +        const cssFileName = mapping[matchedKey]; +        if (cssFileName) { +          browser.storage.sync.get(cssFileName).then((data) => { +            if (data[cssFileName]) { +              let style = document.createElement("style"); +              style.textContent = data[cssFileName]; +              document.head.appendChild(style); +              console.log(`Injected custom CSS for ${currentUrl}`); +            } +          }); +        } +      }); +  }  }); | 
