Skip to content

Commit 525a036

Browse files
committed
新增 [自定义 模式3 排除目标] 选项(还是 自定义当前模式 里)
1 parent 1507306 commit 525a036

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

DarkMode.user.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:zh-CN 护眼模式
44
// @name:zh-TW 護眼模式
55
// @name:en Dark Mode
6-
// @version 1.3.8
6+
// @version 1.3.9
77
// @author X.I.U
88
// @description 简单有效的全网通用护眼模式(夜间模式、暗黑模式、深色模式)
99
// @description:zh-CN 简单有效的全网通用护眼模式(夜间模式、暗黑模式、深色模式)
@@ -34,7 +34,7 @@
3434
['menu_autoRecognition', '智能排除自带暗黑模式的网页 (beta)', '智能排除自带暗黑模式的网页 (beta)', true],
3535
['menu_forcedToEnable', '✅ 已强制当前网站启用护眼模式 (👆)', '❌ 未强制当前网站启用护眼模式 (👆)', []],
3636
['menu_darkModeType', '点击切换模式', '点击切换模式', 2],
37-
['menu_customMode', '自定义当前模式', '自定义当前模式', true], ['menu_customMode1',,,'80|70'], ['menu_customMode2',,,'80|20|70|30'], ['menu_customMode3',,,'90'],
37+
['menu_customMode', '自定义当前模式', '自定义当前模式', true], ['menu_customMode1',,,'80|70'], ['menu_customMode2',,,'80|20|70|30'], ['menu_customMode3',,,'90'], ['menu_customMode3_exclude',,,'img, .img, video, [style*="background"][style*="url"], svg'],
3838
['menu_customTime', '自定义昼夜时间', '自定义昼夜时间', '6|18'],
3939
['menu_autoSwitch', '晚上自动切换模式', '晚上自动切换模式', ''],
4040
], menu_ID = [];
@@ -86,7 +86,7 @@
8686
GM_setValue(menu_ALL[i][0], menu_ALL[i][3]);
8787
menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function(){menu_customTime()});
8888
}
89-
else if (menu_ALL[i][0] === 'menu_customMode1' || menu_ALL[i][0] === 'menu_customMode2' || menu_ALL[i][0] === 'menu_customMode3')
89+
else if (menu_ALL[i][0] === 'menu_customMode1' || menu_ALL[i][0] === 'menu_customMode2' || menu_ALL[i][0] === 'menu_customMode3' || menu_ALL[i][0] === 'menu_customMode3_exclude')
9090
{ // 当前模式值
9191
GM_setValue(menu_ALL[i][0], menu_ALL[i][3]);
9292
}
@@ -179,6 +179,19 @@
179179
GM_setValue(`${name}`, newMods);
180180
registerMenuCommand(); // 重新注册脚本菜单
181181
}
182+
if (getAutoSwitch() == 3) {
183+
tip = '自定义 [模式 3] 排除目标,修改后立即生效 (部分网页可能需要刷新)~\n格式:CSS 选择器 (如果不会写可以找我)\n默认:img, .img, video, [style*="background"][style*="url"], svg\n (使用英文逗号间隔,末尾不要有逗号)';
184+
defaults = 'img, .img, video, [style*="background"][style*="url"], svg';
185+
name = 'menu_customMode3_exclude';
186+
newMods = prompt(tip, GM_getValue(`${name}`));
187+
if (newMods === '') {
188+
GM_setValue(`${name}`, defaults);
189+
registerMenuCommand(); // 重新注册脚本菜单
190+
} else if (newMods != null) {
191+
GM_setValue(`${name}`, newMods);
192+
registerMenuCommand(); // 重新注册脚本菜单
193+
}
194+
}
182195
if (document.getElementById('XIU2DarkMode')) {
183196
document.getElementById('XIU2DarkMode').remove(); // 即时修改样式
184197
addStyle();
@@ -341,8 +354,12 @@
341354
style_21_firefox = `html {filter: brightness(${style_20[0]}%) sepia(${style_20[1]}%) !important; background-image: url();}`,
342355
style_22 = `html {filter: brightness(${style_20[2]}%) sepia(${style_20[3]}%) !important;}`,
343356
style_22_firefox = `html {filter: brightness(${style_20[2]}%) sepia(${style_20[3]}%) !important; background-image: url();}`,
344-
style_31 = `html {filter: invert(${style_30[0]}%) !important; text-shadow: 0 0 0 !important;} img, video, [style*="background"][style*="url"], svg {filter: invert(1) !important;} img[alt="[公式]"] {filter: none !important;}`,
345-
style_31_firefox = `html {filter: invert(${style_30[0]}%) !important; background-image: url(); text-shadow: 0 0 0 !important;} img, video, [style*="background"][style*="url"], svg {filter: invert(1) !important;} img[alt="[公式]"] {filter: none !important;}`;
357+
style_31 = `html {filter: invert(${style_30[0]}%) !important; text-shadow: 0 0 0 !important;}
358+
${menu_value('menu_customMode3_exclude')} {filter: invert(1) !important;}
359+
img[alt="[公式]"] {filter: none !important;}`,
360+
style_31_firefox = `html {filter: invert(${style_30[0]}%) !important; background-image: url(); text-shadow: 0 0 0 !important;}
361+
${menu_value('menu_customMode3_exclude')} {filter: invert(1) !important;}
362+
img[alt="[公式]"] {filter: none !important;}`;
346363

347364
// Firefox 浏览器需要特殊对待
348365
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {

0 commit comments

Comments
 (0)