summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--background.js14
-rw-r--r--inject-css.js21
-rw-r--r--popup/popup.html4
-rw-r--r--popup/popup.js59
4 files changed, 29 insertions, 69 deletions
diff --git a/background.js b/background.js
index cd2769a..0cf6b1b 100644
--- a/background.js
+++ b/background.js
@@ -99,16 +99,16 @@ browser.storage.local.get("transparentZenSettings").then((settings) => {
});
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
- if (logging) console.log("onUpdated called with", tabId, changeInfo, tab);
+ // if (logging) console.log("onUpdated called with", tabId, changeInfo, tab);
// Apply CSS when a tab is updated
if (changeInfo.status === "complete") {
applyCSSToTab(tab);
}
});
-browser.tabs.onActivated.addListener(async (activeInfo) => {
- if (logging) console.log("onActivated called with", activeInfo);
- // Apply CSS when a tab is activated
- const tab = await browser.tabs.get(activeInfo.tabId);
- applyCSSToTab(tab);
-});
+// browser.tabs.onActivated.addListener(async (activeInfo) => {
+// if (logging) console.log("onActivated called with", activeInfo);
+// // Apply CSS when a tab is activated
+// const tab = await browser.tabs.get(activeInfo.tabId);
+// applyCSSToTab(tab);
+// });
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");
}
});
diff --git a/popup/popup.html b/popup/popup.html
index b53ed87..4c20a90 100644
--- a/popup/popup.html
+++ b/popup/popup.html
@@ -36,13 +36,13 @@
</div>
<!-- All Websites Section (Collapsible) -->
- <div class="websites-container">
+ <!-- <div class="websites-container">
<button class="collapsible-button" id="toggle-websites">
<span>All Websites</span>
<i class="fas fa-chevron-down"></i>
</button>
<div id="websites-list" class="websites-list collapsed"></div>
- </div>
+ </div> -->
<div class="actions">
<button id="refetch-css" class="action-button primary">
diff --git a/popup/popup.js b/popup/popup.js
index 113b99e..595efb9 100644
--- a/popup/popup.js
+++ b/popup/popup.js
@@ -26,10 +26,6 @@ new (class ExtensionPopup {
// Bind event listeners
this.refetchCSSButton.addEventListener("click", this.refetchCSS.bind(this));
- document.getElementById("toggle-websites").addEventListener("click", () => {
- this.websitesList.classList.toggle("collapsed");
- });
-
this.autoUpdateSwitch.addEventListener(
"change",
this.saveSettings.bind(this)
@@ -38,7 +34,6 @@ new (class ExtensionPopup {
// Setup auto-update and display last fetched time
this.setupAutoUpdate();
this.displayLastFetchedTime();
- this.setupContentScriptInjection();
this.displayAddonVersion();
}
@@ -86,7 +81,6 @@ new (class ExtensionPopup {
this.autoUpdateSwitch.checked = this.browserStorageSettings.autoUpdate;
}
this.loadCurrentSiteFeatures();
- this.loadWebsitesList();
}
async loadSettings() {
@@ -120,7 +114,6 @@ new (class ExtensionPopup {
browser.storage.local.set({
[this.BROWSER_STORAGE_KEY]: this.browserStorageSettings,
});
-
console.info("Settings saved", this.browserStorageSettings);
}
@@ -181,38 +174,6 @@ new (class ExtensionPopup {
}
}
- async loadWebsitesList() {
- if (logging) console.log("loadWebsitesList called");
- // Load the list of websites with available styles
- try {
- const stylesData = await browser.storage.local.get("styles");
- const styles = stylesData.styles?.website || {};
-
- this.websitesList.innerHTML = "";
-
- const websites = Object.keys(styles);
-
- if (websites.length === 0) {
- const listItem = document.createElement("li");
- listItem.textContent =
- "No styles available. Click 'Refetch latest styles' to update.";
- this.websitesList.appendChild(listItem);
- return;
- }
-
- for (const site of websites) {
- const displayName = site.replace(/\.css$/, "");
- const listItem = document.createElement("li");
- listItem.textContent = displayName;
- this.websitesList.appendChild(listItem);
- }
- } catch (error) {
- console.error("Error loading websites list:", error);
- this.websitesList.innerHTML =
- "<li>Error loading websites list. Please try refetching styles.</li>";
- }
- }
-
isCurrentSite(siteName) {
if (logging) console.log("isCurrentSite called with", siteName);
// Check if the given site name matches the current site hostname
@@ -259,26 +220,6 @@ new (class ExtensionPopup {
}
}
- setupContentScriptInjection() {
- if (logging) console.log("setupContentScriptInjection called");
- // Setup content script injection for tab updates
- browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
- if (changeInfo.status === "complete") {
- this.applyCSSToTab(tab);
- }
- });
- this.updateAllTabs();
- }
-
- async updateAllTabs() {
- if (logging) console.log("updateAllTabs called");
- // Update CSS for all open tabs
- const tabs = await browser.tabs.query({});
- for (const tab of tabs) {
- this.applyCSSToTab(tab);
- }
- }
-
async updateActiveTabStyling() {
if (logging) console.log("updateActiveTabStyling called");
// Update CSS for the active tab