Skip to content

Commit 6e3e02d

Browse files
committed
Website specific toggling
1 parent cd3f9cf commit 6e3e02d

File tree

6 files changed

+53
-1
lines changed

6 files changed

+53
-1
lines changed

.DS_Store

6 KB
Binary file not shown.

inject-css.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ browser.storage.sync.get("transparentZenSettings").then((settings) => {
88
currentUrl.includes(key)
99
);
1010
const cssFileName = mapping[matchedKey];
11-
if (cssFileName) {
11+
if (
12+
cssFileName &&
13+
settings.transparentZenSettings.websiteSettings?.[matchedKey] !==
14+
false
15+
) {
1216
browser.storage.sync.get(cssFileName).then((data) => {
1317
if (data[cssFileName]) {
1418
let style = document.createElement("style");

manifest.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
"name": "Zen Internet",
44
"version": "0.2.0",
55
"description": "Inject custom css from my repository in real time",
6+
"browser_specific_settings": {
7+
"gecko": {
8+
"id": "{91aa3897-2634-4a8a-9092-279db23a7689}"
9+
}
10+
},
611
"icons": {
712
"48": "assets/images/logo_48.png",
813
"96": "assets/images/logo_96.png"

mapper.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"github.com": "github.com.css",
33
"keep.google.com": "keep.google.com.css",
44
"aistudio.google.com": "aistudio.google.com.css",
5+
"calendar.google.com": "calendar.google.com.css",
56
"chat.openai.com": "chat.openai.com.css",
7+
"chat.deepseek.com": "chat.deepseek.com.css",
68
"discord.com.css": "discord.com.css",
79
"facebook.com": "facebook.com.css",
810
"gemini.google.com": "gemini.google.com.css",

popup/popup.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ <h1 class="headline">ZenInternet by @sameerasw</h1>
1616
<input type="checkbox" id="enable-styling">
1717
Enable Styling
1818
</label>
19+
<ul id="websites-list"></ul>
1920
<button id="refetch-css">Refetch latest styles</button>
2021
<button id="restart-background">Restart Background Script (optional)</button>
2122
<a href="https://sameerasw.github.io/my-internet/">Styles repo</a>

popup/popup.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ new (class ExtensionPopup {
33
browserStorageSettings = {};
44
enableStylingSwitch = document.getElementById("enable-styling");
55
refetchCSSButton = document.getElementById("refetch-css");
6+
websitesList = document.getElementById("websites-list");
67

78
constructor() {
89
this.loadSettings().then((settings) => {
@@ -22,13 +23,17 @@ new (class ExtensionPopup {
2223
this.enableStylingSwitch.addEventListener("change", () => {
2324
this.saveSettings();
2425
});
26+
this.websitesList.addEventListener("change", () => {
27+
this.saveSettings();
28+
});
2529
}
2630

2731
restoreSettings() {
2832
if (this.browserStorageSettings.enableStyling !== undefined) {
2933
this.enableStylingSwitch.checked =
3034
this.browserStorageSettings.enableStyling;
3135
}
36+
this.loadWebsitesList();
3237
}
3338

3439
async loadSettings() {
@@ -41,6 +46,14 @@ new (class ExtensionPopup {
4146
this.browserStorageSettings.enableStyling =
4247
this.enableStylingSwitch.checked;
4348

49+
const websiteSettings = {};
50+
this.websitesList
51+
.querySelectorAll("input[type=checkbox]")
52+
.forEach((checkbox) => {
53+
websiteSettings[checkbox.name] = checkbox.checked;
54+
});
55+
this.browserStorageSettings.websiteSettings = websiteSettings;
56+
4457
browser.storage.local.set({
4558
[this.BROWSER_STORAGE_KEY]: this.browserStorageSettings,
4659
});
@@ -50,6 +63,33 @@ new (class ExtensionPopup {
5063
console.info("Settings saved", this.browserStorageSettings);
5164
}
5265

66+
async loadWebsitesList() {
67+
try {
68+
const response = await fetch("/mapper.json", {
69+
headers: {
70+
"Cache-Control": "no-cache",
71+
},
72+
});
73+
if (!response.ok) throw new Error("Failed to fetch mapper.json");
74+
const mapping = await response.json();
75+
this.websitesList.innerHTML = "";
76+
for (const site of Object.keys(mapping)) {
77+
const isChecked =
78+
this.browserStorageSettings.websiteSettings?.[site] ?? true;
79+
const listItem = document.createElement("li");
80+
listItem.innerHTML = `
81+
<label>
82+
<input type="checkbox" name="${site}" ${isChecked ? "checked" : ""}>
83+
${site}
84+
</label>
85+
`;
86+
this.websitesList.appendChild(listItem);
87+
}
88+
} catch (error) {
89+
console.error("Error loading websites list:", error);
90+
}
91+
}
92+
5393
async refetchCSS() {
5494
this.refetchCSSButton.textContent = "Fetching...";
5595
try {

0 commit comments

Comments
 (0)