Skip to content

Commit d5d26e9

Browse files
committed
feat: Add settings categories and remove incompatible Nyaa mirror
- Added categorized settings in popup UI for better organization: - Download Settings - Interface Settings - Additional Features - Removed 'nyaa.eu' from supported domains list due to incompatibility - Improved settings layout with category headers and dividers - Reorganized toggle buttons into logical groups
1 parent 7d06be5 commit d5d26e9

File tree

8 files changed

+207
-111
lines changed

8 files changed

+207
-111
lines changed

src/chrome/background.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Array of supported Nyaa domains from manifest.json
22
const supportedDomains = [
33
"nyaa.si",
4-
"nyaa.eu",
54
"nya.iss.one",
65
"nyaa.ink",
76
"nyaa.land",
@@ -14,16 +13,19 @@ function isNyaaSite(url) {
1413
return supportedDomains.some((domain) => url.includes(domain));
1514
}
1615

17-
// Update badge when tabs change
18-
chrome.tabs.onActivated.addListener(async (activeInfo) => {
19-
const tab = await chrome.tabs.get(activeInfo.tabId);
20-
updateBadge(tab.url);
16+
// Update badge and popup state when tab changes
17+
chrome.tabs.onActivated.addListener((activeInfo) => {
18+
chrome.tabs.get(activeInfo.tabId, (tab) => {
19+
updateBadge(tab.url);
20+
updatePopupState(tab.url);
21+
});
2122
});
2223

23-
// Update badge when URLs change
24+
// Update badge and popup state when URL changes
2425
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
2526
if (changeInfo.url) {
2627
updateBadge(changeInfo.url);
28+
updatePopupState(changeInfo.url);
2729
}
2830
});
2931

@@ -35,3 +37,13 @@ function updateBadge(url) {
3537
chrome.action.setBadgeText({ text: "" });
3638
}
3739
}
40+
41+
function updatePopupState(url) {
42+
if (url && isNyaaSite(url)) {
43+
chrome.action.enable();
44+
chrome.action.setPopup({ popup: "popup.html" });
45+
} else {
46+
chrome.action.disable();
47+
chrome.action.setPopup({ popup: "" });
48+
}
49+
}

src/chrome/manifest.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"permissions": ["clipboardWrite", "storage", "activeTab"],
1010
"host_permissions": [
1111
"*://*.nyaa.si/*",
12-
"*://*.nyaa.eu/*",
1312
"*://*.nya.iss.one/*",
1413
"*://*.nyaa.ink/*",
1514
"*://*.nyaa.land/*",
@@ -25,7 +24,6 @@
2524
{
2625
"matches": [
2726
"*://*.nyaa.si/*",
28-
"*://*.nyaa.eu/*",
2927
"*://*.nya.iss.one/*",
3028
"*://*.nyaa.ink/*",
3129
"*://*.nyaa.land/*",

src/chrome/popup.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ body {
66
color: #fff;
77
font-size: 14px;
88
line-height: 1.5;
9+
scrollbar-width: thin;
10+
scrollbar-color: #3a3a3a #1a1a1a;
911
}
1012

1113
.nav-container {
@@ -44,6 +46,8 @@ body {
4446
padding: 20px;
4547
font-family: "Segoe UI", Tahoma, sans-serif;
4648
font-weight: 500;
49+
max-height: 400px;
50+
overflow-y: auto;
4751
}
4852

4953
.tab-content {
@@ -137,3 +141,22 @@ body {
137141
color: #66bb6a;
138142
text-decoration: underline;
139143
}
144+
145+
.settings-category {
146+
margin-bottom: 20px;
147+
}
148+
149+
.category-title {
150+
font-size: 14px;
151+
font-weight: 600;
152+
color: rgb(192, 192, 192);
153+
margin: 0 0 12px 0;
154+
padding-bottom: 8px;
155+
border-bottom: 1px solid #eee;
156+
}
157+
158+
/* Dark mode support */
159+
.dark .category-title {
160+
color: #aaa;
161+
border-bottom-color: #444;
162+
}

src/chrome/popup.html

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,66 +12,81 @@
1212

1313
<div class="content-container">
1414
<div id="settings" class="tab-content active">
15-
<div class="setting-item">
16-
<span>Use display name as filename</span>
17-
<div class="toggle-container">
18-
<button class="toggle-button" data-toggle="displayNameToggle">
19-
<span class="toggle-indicator"></span>
20-
</button>
15+
<!-- Download Settings -->
16+
<div class="settings-category">
17+
<h3 class="category-title">Download Settings</h3>
18+
<div class="setting-item">
19+
<span>Use display name as filename</span>
20+
<div class="toggle-container">
21+
<button class="toggle-button" data-toggle="displayNameToggle">
22+
<span class="toggle-indicator"></span>
23+
</button>
24+
</div>
2125
</div>
22-
</div>
2326

24-
<div class="setting-item">
25-
<span>Combine downloads as ZIP</span>
26-
<div class="toggle-container">
27-
<button class="toggle-button" data-toggle="zipToggle">
28-
<span class="toggle-indicator"></span>
29-
</button>
27+
<div class="setting-item">
28+
<span>Combine downloads as ZIP</span>
29+
<div class="toggle-container">
30+
<button class="toggle-button" data-toggle="zipToggle">
31+
<span class="toggle-indicator"></span>
32+
</button>
33+
</div>
3034
</div>
3135
</div>
3236

33-
<div class="setting-item">
34-
<span>Show button controls</span>
35-
<div class="toggle-container">
36-
<button class="toggle-button" data-toggle="showButtonsToggle">
37-
<span class="toggle-indicator"></span>
38-
</button>
37+
<!-- Interface Settings -->
38+
<div class="settings-category">
39+
<h3 class="category-title">Interface Settings</h3>
40+
<div class="setting-item">
41+
<span>Show Button Controls</span>
42+
<div class="toggle-container">
43+
<button class="toggle-button" data-toggle="showButtonsToggle">
44+
<span class="toggle-indicator"></span>
45+
</button>
46+
</div>
3947
</div>
40-
</div>
4148

42-
<div class="setting-item">
43-
<span>Show Quick Filter button</span>
44-
<div class="toggle-container">
45-
<button class="toggle-button" data-toggle="showQuickFilterToggle">
46-
<span class="toggle-indicator"></span>
47-
</button>
49+
<div class="setting-item">
50+
<span>Show Quick Filter Button</span>
51+
<div class="toggle-container">
52+
<button class="toggle-button" data-toggle="showQuickFilterToggle">
53+
<span class="toggle-indicator"></span>
54+
</button>
55+
</div>
4856
</div>
49-
</div>
5057

51-
<div class="setting-item">
52-
<span>Show Animetosho links</span>
53-
<div class="toggle-container">
54-
<button class="toggle-button" data-toggle="showATLinksToggle">
55-
<span class="toggle-indicator"></span>
56-
</button>
58+
<div class="setting-item">
59+
<span>Show Mgnet Copy Buttons</span>
60+
<div class="toggle-container">
61+
<button
62+
class="toggle-button"
63+
data-toggle="showMagnetButtonsToggle"
64+
>
65+
<span class="toggle-indicator"></span>
66+
</button>
67+
</div>
5768
</div>
5869
</div>
5970

60-
<div class="setting-item">
61-
<span>Show magnet copy buttons</span>
62-
<div class="toggle-container">
63-
<button class="toggle-button" data-toggle="showMagnetButtonsToggle">
64-
<span class="toggle-indicator"></span>
65-
</button>
71+
<!-- Additional Features -->
72+
<div class="settings-category">
73+
<h3 class="category-title">Additional Features</h3>
74+
<div class="setting-item">
75+
<span>Show Animetosho Links</span>
76+
<div class="toggle-container">
77+
<button class="toggle-button" data-toggle="showATLinksToggle">
78+
<span class="toggle-indicator"></span>
79+
</button>
80+
</div>
6681
</div>
67-
</div>
6882

69-
<div class="setting-item">
70-
<span>Show changelogs</span>
71-
<div class="toggle-container">
72-
<button class="toggle-button" data-toggle="changelogToggle">
73-
<span class="toggle-indicator"></span>
74-
</button>
83+
<div class="setting-item">
84+
<span>Show Changelogs</span>
85+
<div class="toggle-container">
86+
<button class="toggle-button" data-toggle="changelogToggle">
87+
<span class="toggle-indicator"></span>
88+
</button>
89+
</div>
7590
</div>
7691
</div>
7792
</div>

src/firefox/background.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Array of supported Nyaa domains from manifest.json
22
const supportedDomains = [
33
"nyaa.si",
4-
"nyaa.eu",
54
"nya.iss.one",
65
"nyaa.ink",
76
"nyaa.land",
@@ -14,24 +13,37 @@ function isNyaaSite(url) {
1413
return supportedDomains.some((domain) => url.includes(domain));
1514
}
1615

17-
// Update badge when tabs change
18-
browser.tabs.onActivated.addListener(async (activeInfo) => {
19-
const tab = await browser.tabs.get(activeInfo.tabId);
20-
updateBadge(tab.url);
16+
// Update badge and popup state when tab changes
17+
browser.tabs.onActivated.addListener((activeInfo) => {
18+
browser.tabs.get(activeInfo.tabId, (tab) => {
19+
updateBadge(tab.url);
20+
updatePopupState(tab.url);
21+
});
2122
});
2223

23-
// Update badge when URLs change
24+
// Update badge and popup state when URL changes
2425
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
2526
if (changeInfo.url) {
2627
updateBadge(changeInfo.url);
28+
updatePopupState(changeInfo.url);
2729
}
2830
});
2931

3032
function updateBadge(url) {
3133
if (url && isNyaaSite(url)) {
32-
browser.browserAction.setBadgeText({ text: "On" });
33-
browser.browserAction.setBadgeBackgroundColor({ color: "#4CAF50" });
34+
browser.action.setBadgeText({ text: "On" });
35+
browser.action.setBadgeBackgroundColor({ color: "#4CAF50" });
3436
} else {
35-
browser.browserAction.setBadgeText({ text: "" });
37+
browser.action.setBadgeText({ text: "" });
38+
}
39+
}
40+
41+
function updatePopupState(url) {
42+
if (url && isNyaaSite(url)) {
43+
browser.action.enable();
44+
browser.action.setPopup({ popup: "popup.html" });
45+
} else {
46+
browser.action.disable();
47+
browser.action.setPopup({ popup: "" });
3648
}
3749
}

src/firefox/manifest.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"storage",
1212
"activeTab",
1313
"*://*.nyaa.si/*",
14-
"*://*.nyaa.eu/*",
1514
"*://*.nya.iss.one/*",
1615
"*://*.nyaa.ink/*",
1716
"*://*.nyaa.land/*",
@@ -27,7 +26,6 @@
2726
{
2827
"matches": [
2928
"*://*.nyaa.si/*",
30-
"*://*.nyaa.eu/*",
3129
"*://*.nya.iss.one/*",
3230
"*://*.nyaa.ink/*",
3331
"*://*.nyaa.land/*",

src/firefox/popup.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ body {
66
color: #fff;
77
font-size: 14px;
88
line-height: 1.5;
9+
scrollbar-width: thin;
10+
scrollbar-color: #3a3a3a #1a1a1a;
911
}
1012

1113
.nav-container {
@@ -44,6 +46,8 @@ body {
4446
padding: 20px;
4547
font-family: "Segoe UI", Tahoma, sans-serif;
4648
font-weight: 500;
49+
max-height: 400px;
50+
overflow-y: auto;
4751
}
4852

4953
.tab-content {
@@ -137,3 +141,22 @@ body {
137141
color: #66bb6a;
138142
text-decoration: underline;
139143
}
144+
145+
.settings-category {
146+
margin-bottom: 20px;
147+
}
148+
149+
.category-title {
150+
font-size: 14px;
151+
font-weight: 600;
152+
color: rgb(192, 192, 192);
153+
margin: 0 0 12px 0;
154+
padding-bottom: 8px;
155+
border-bottom: 1px solid #eee;
156+
}
157+
158+
/* Dark mode support */
159+
.dark .category-title {
160+
color: #aaa;
161+
border-bottom-color: #444;
162+
}

0 commit comments

Comments
 (0)