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

Function registerMenuCommand

Lanzou-Enhanced.user.js:101–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

99
100 // 注册脚本菜单
101 function registerMenuCommand() {
102 if (menu_ID.length > menu_ALL.length){ // 如果菜单ID数组多于菜单数组,说明不是首次添加菜单,需要卸载所有脚本菜单
103 for (let i=0;i<menu_ID.length;i++){
104 GM_unregisterMenuCommand(menu_ID[i]);
105 }
106 }
107 for (let i=0;i<menu_ALL.length;i++){ // 循环注册脚本菜单
108 menu_ALL[i][3] = GM_getValue(menu_ALL[i][0]);
109 if (menu_ALL[i][0] == 'menu_refreshCorrection') {
110 menu_ID[i] = GM_registerMenuCommand(`${menu_ALL[i][3]?'✅':'❌'} ${menu_ALL[i][1]}`, function(){if(menu_value('menu_refreshCorrection')){UNrefreshCorrection();}else{refreshCorrection();};menu_switch(`${menu_ALL[i][3]}`,`${menu_ALL[i][0]}`,`${menu_ALL[i][2]}`)});
111 } else if (menu_ALL[i][0] === 'menu_customFileSha') {
112 menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function(){customFileSha()});
113 } else {
114 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]}`)});
115 }
116 }
117 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/419224/feedback', {active: true,insert: true,setParent: true});});
118 }
119
120 // 菜单开关
121 function menu_switch(menu_status, Name, Tips) {

Callers 3

menu_switchFunction · 0.70
customFileShaFunction · 0.70

Calls 5

UNrefreshCorrectionFunction · 0.85
refreshCorrectionFunction · 0.85
customFileShaFunction · 0.85
menu_valueFunction · 0.70
menu_switchFunction · 0.70

Tested by

no test coverage detected