(menu_status, Name, Tips)
| 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) { |
no test coverage detected