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

Function registerMenuCommand

DuckDuckGo-Enhanced.user.js:38–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 3

menu_switchFunction · 0.70
customBlockDomainFunction · 0.70

Calls 2

customBlockDomainFunction · 0.85
menu_switchFunction · 0.70

Tested by

no test coverage detected