blob: de2715e5c5eec71622033604267bedab8daf1856 (
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
30
31
32
33
|
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?.website || {}).find(
(key) => {
const siteName = key.replace(".css", "");
return currentUrl === siteName || currentUrl === `www.${siteName}`;
}
);
if (cssFileName) {
const features = data.styles.website[cssFileName];
const featureSettings =
settings.transparentZenSettings.featureSettings?.[cssFileName] || {};
let combinedCSS = "";
for (const [feature, css] of Object.entries(features)) {
if (featureSettings[feature] !== false) {
combinedCSS += css + "\n";
}
}
if (combinedCSS) {
let style = document.createElement("style");
style.textContent = combinedCSS;
document.head.appendChild(style);
console.log(`Injected custom CSS for ${currentUrl}`);
}
}
});
}
});
|