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

Function registerMenuCommand

V2ex-Enhanced.user.js:44–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43 // 注册脚本菜单
44 function registerMenuCommand() {
45 if (menu_ID.length > menu_ALL.length){ // 如果菜单ID数组多于菜单数组,说明不是首次添加菜单,需要卸载所有脚本菜单
46 for (let i=0;i<menu_ID.length;i++){
47 GM_unregisterMenuCommand(menu_ID[i]);
48 }
49 }
50 for (let i=0;i<menu_ALL.length;i++){ // 循环注册脚本菜单
51 menu_ALL[i][3] = GM_getValue(menu_ALL[i][0]);
52 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]}`)});
53 }
54 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/424246/feedback', {active: true,insert: true,setParent: true});});
55 }
56
57 // 菜单开关
58 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