summaryrefslogtreecommitdiff
path: root/inject-css.js
diff options
context:
space:
mode:
authorsameerasw <[email protected]>2025-02-27 22:00:35 +0530
committersameerasw <[email protected]>2025-02-27 22:00:35 +0530
commit9e8de1c7b8ab58b12924cedfb7284af58f5b8181 (patch)
tree6204c44144e4dfb9cda386ec7f4045c6cc73e86f /inject-css.js
parente6179900efbd867cad38536e645d620ffa2f74c5 (diff)
disabled style update on switching tabs
Diffstat (limited to 'inject-css.js')
-rw-r--r--inject-css.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/inject-css.js b/inject-css.js
index de2715e..db19b3d 100644
--- a/inject-css.js
+++ b/inject-css.js
@@ -1,7 +1,19 @@
+let logging = true;
+
+if (logging) console.log("inject-css.js script loaded");
+
browser.storage.local.get("transparentZenSettings").then((settings) => {
+ if (logging) console.log("Settings loaded", settings);
+
if (settings.transparentZenSettings?.enableStyling) {
+ if (logging) console.log("Styling is enabled");
+
browser.storage.local.get("styles").then((data) => {
+ if (logging) console.log("Styles data loaded", data);
+
const currentUrl = window.location.hostname;
+ if (logging) console.log("Current URL hostname", currentUrl);
+
const cssFileName = Object.keys(data.styles?.website || {}).find(
(key) => {
const siteName = key.replace(".css", "");
@@ -10,6 +22,9 @@ browser.storage.local.get("transparentZenSettings").then((settings) => {
);
if (cssFileName) {
+ if (logging)
+ console.log("CSS file found for current site", cssFileName);
+
const features = data.styles.website[cssFileName];
const featureSettings =
settings.transparentZenSettings.featureSettings?.[cssFileName] || {};
@@ -25,9 +40,13 @@ browser.storage.local.get("transparentZenSettings").then((settings) => {
let style = document.createElement("style");
style.textContent = combinedCSS;
document.head.appendChild(style);
- console.log(`Injected custom CSS for ${currentUrl}`);
+ if (logging) console.log(`Injected custom CSS for ${currentUrl}`);
}
+ } else {
+ if (logging) console.log("No CSS file found for current site");
}
});
+ } else {
+ if (logging) console.log("Styling is disabled");
}
});