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

Function registerMenuCommand

Hostloc-Enhanced.user.js:42–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 registerMenuCommand();
41 // 注册脚本菜单
42 function registerMenuCommand() {
43 if (menu_ID.length > menu_ALL.length) { // 如果菜单ID数组多于菜单数组,说明不是首次添加菜单,需要卸载所有脚本菜单
44 for (let i = 0; i < menu_ID.length; i++) {
45 GM_unregisterMenuCommand(menu_ID[i]);
46 }
47 }
48 for (let i = 0; i < menu_ALL.length; i++) { // 循环注册脚本菜单
49 menu_ALL[i][3] = GM_getValue(menu_ALL[i][0]);
50 if (menu_ALL[i][0] === 'menu_reAutoSignIn') {
51 menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function () { reAutoSignIn() });
52 } else if (menu_ALL[i][0] === 'menu_customBlockUsers') {
53 menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function () { customBlockUsers() });
54 } else if (menu_ALL[i][0] === 'menu_customBlockKeywords') {
55 menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function () { customBlockKeywords() });
56 } else if (menu_ALL[i][0] === 'menu_customLittleTail') {
57 if (menu_value(menu_ALL[i][0]).length === 0) { GM_setValue(menu_ALL[i][0], '') } // 修改旧版类型
58 menu_ID[i] = GM_registerMenuCommand(`#️⃣ ${menu_ALL[i][1]}`, function () { customLittleTail() });
59 } else {
60 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]}`) });
61 }
62 }
63 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/414005/feedback', { active: true, insert: true, setParent: true }); });
64 }
65 // 菜单开关
66 function menu_switch(menu_status, Name, Tips) {
67 if (menu_status == 'true') {

Callers 5

menu_switchFunction · 0.70
customBlockUsersFunction · 0.70
customBlockKeywordsFunction · 0.70
customLittleTailFunction · 0.70

Calls 6

reAutoSignInFunction · 0.85
customLittleTailFunction · 0.85
customBlockUsersFunction · 0.70
customBlockKeywordsFunction · 0.70
menu_valueFunction · 0.70
menu_switchFunction · 0.70

Tested by

no test coverage detected