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

Function registerMenuCommand

Zhiyoo-Enhanced.user.js:39–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37
38 // 注册脚本菜单
39 function registerMenuCommand() {
40 if (menu_ID.length > menu_ALL.length){ // 如果菜单ID数组多于菜单数组,说明不是首次添加菜单,需要卸载所有脚本菜单
41 for (let i=0;i<menu_ID.length;i++){
42 GM_unregisterMenuCommand(menu_ID[i]);
43 }
44 }
45 for (let i=0;i<menu_ALL.length;i++){ // 循环注册脚本菜单
46 menu_ALL[i][3] = GM_getValue(menu_ALL[i][0]);
47 if (menu_ALL[i][0] == 'menu_qianDaoRedirectURL') {
48 menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function(){GM_setValue(`${menu_ALL[i][0]}`, location.href);GM_notification({text: `${menu_ALL[i][2]}`, timeout: 3000});})
49 } else {
50 menu_ID[i] = GM_registerMenuCommand(`${menu_ALL[i][3]?'✅':'❌'} ${menu_ALL[i][1]}`, function(){menu_switch(`${menu_ALL[i][3]}`,`${menu_ALL[i][0]}`,`${menu_ALL[i][2]}`)});
51 }
52 }
53 menu_ID[menu_ID.length] = GM_registerMenuCommand('💬 反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/412362/feedback', {active: true,insert: true,setParent: true});});
54 }
55
56 // 菜单开关
57 function menu_switch(menu_status, Name, Tips) {

Callers 2

menu_switchFunction · 0.70

Calls 1

menu_switchFunction · 0.70

Tested by

no test coverage detected