MCPcopy Create free account
hub / github.com/XIU2/UserScript / menu_switch

Function menu_switch

Zhihu-Beautification.user.js:100–123  ·  view source on GitHub ↗
(menu_status, Name, Tips)

Source from the content-addressed store, hash-verified

98
99 // 菜单开关
100 function menu_switch(menu_status, Name, Tips) {
101 if (menu_status == 'true'){
102 GM_setValue(`${Name}`, false);
103
104 if (Name === 'menu_darkMode') { // 暗黑模式
105 if (getTheme() === 'dark') {setTheme('light');} else {location.reload();}
106 } else {
107 GM_notification({text: `已关闭 [${Tips}] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});
108 }
109 } else {
110 GM_setValue(`${Name}`, true);
111
112 if (Name === 'menu_darkMode') {
113 if (menu_value('menu_darkModeType') === 1) {
114 if (getTheme() === 'light') setTheme('dark');
115 } else {
116 if (getTheme() === 'dark') {setTheme('light');} else {location.reload();}
117 }
118 } else {
119 GM_notification({text: `已开启 [${Tips}] 功能\n(点击刷新网页后生效)`, timeout: 3500, onclick: function(){location.reload();}});
120 }
121 }
122 registerMenuCommand(); // 重新注册脚本菜单
123 };
124
125 // 返回菜单值
126 function menu_value(menuName) {

Callers 1

registerMenuCommandFunction · 0.70

Calls 4

getThemeFunction · 0.85
setThemeFunction · 0.85
menu_valueFunction · 0.70
registerMenuCommandFunction · 0.70

Tested by

no test coverage detected