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

Function menu_disable

DarkMode.user.js:262–298  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

260
261 // 启用/禁用护眼模式 (当前网站)
262 function menu_disable(type) {
263 switch(type) {
264 case 'check':
265 if(check()) return true
266 return false
267 break;
268 case 'add':
269 add();
270 break;
271 case 'del':
272 del();
273 break;
274 }
275
276 function check() { // 存在返回真,不存在返回假
277 let websiteList = menu_value('menu_disable'); // 读取网站列表
278 if (websiteList.indexOf(location.host) === -1) return false // 不存在返回假
279 return true
280 }
281
282 function add() {
283 if (check()) return
284 let websiteList = menu_value('menu_disable'); // 读取网站列表
285 websiteList.push(location.host); // 追加网站域名
286 GM_setValue('menu_disable', websiteList); // 写入配置
287 location.reload(); // 刷新网页
288 }
289
290 function del() {
291 if (!check()) return
292 let websiteList = menu_value('menu_disable'), // 读取网站列表
293 index = websiteList.indexOf(location.host);
294 websiteList.splice(index, 1); // 删除网站域名
295 GM_setValue('menu_disable', websiteList); // 写入配置
296 location.reload(); // 刷新网页
297 }
298 }
299
300
301 // 切换暗黑模式

Callers 1

registerMenuCommandFunction · 0.70

Calls 3

checkFunction · 0.70
addFunction · 0.70
delFunction · 0.70

Tested by

no test coverage detected