MCPcopy Index your code
hub / github.com/XIU2/UserScript / registerMenuCommand

Function registerMenuCommand

Autopage.user.js:145–184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143 if (menuId.length < 4) {return}
144 // 注册脚本菜单
145 function registerMenuCommand() {
146 if (menuId.length != []){
147 for (let i=0;i<menuId.length;i++){
148 GM_unregisterMenuCommand(menuId[i]);
149 }
150 }
151 for (let i=0;i<menuAll.length;i++) { // 循环注册脚本菜单
152 menuAll[i][3] = GM_getValue(menuAll[i][0]);
153
154 if (menuAll[i][0] === 'menu_disable') { // 启用/禁用
155
156 if (menu_disable('check')) { // 当前网站在禁用列表中
157 menuId[i] = GM_registerMenuCommand(`${menuAll[i][2]}`, function(){menu_disable('del')});
158 return
159 } else { // 不在禁用列表中
160 webType = doesItSupport(); // 判断网站类型(即是否支持),顺便直接赋值
161 if (webType === 0) {
162 menuId[0] = 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/419215/feedback', {active: true,insert: true,setParent: true});});
163 menuId[1] = GM_registerMenuCommand('🔄 更新外置翻页规则 (定期自动)', function(){getRulesUrl(true)});
164 menuId[2] = GM_registerMenuCommand('#️⃣ 自定义翻页规则', function(){customRules()});
165 //console.info('[自动无缝翻页] - 暂不支持当前网页 [ ' + location.href + ' ],申请支持: https://github.com/XIU2/UserScript / https://greasyfork.org/zh-CN/scripts/419215/feedback');
166 return
167 } else if (webType === -1) {
168 return
169 }
170 menuId[i] = GM_registerMenuCommand(`${menuAll[i][1]}`, function(){menu_disable('add')});
171 }
172
173 } else if (menuAll[i][0] === 'menu_rules') {
174 menuId[i] = GM_registerMenuCommand(`🔄 ${menuAll[i][1]}`, function(){getRulesUrl(true)});
175
176 } else if (menuAll[i][0] === 'menu_customRules') {
177 menuId[i] = GM_registerMenuCommand(`#️⃣ ${menuAll[i][1]}`, function(){customRules()});
178
179 } else {
180 menuId[i] = GM_registerMenuCommand(`${menuAll[i][3]?'✅':'❌'} ${menuAll[i][1]}`, function(){menu_switch(menuAll[i][3], menuAll[i][0], menuAll[i][2])});
181 }
182 }
183 menuId[menuId.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/419215/feedback', {active: true,insert: true,setParent: true});});
184 }
185
186
187 // --------------------------------------------------------

Callers 3

Autopage.user.jsFile · 0.70
getRulesUrl_Function · 0.70
menu_switchFunction · 0.70

Calls 5

doesItSupportFunction · 0.85
getRulesUrlFunction · 0.85
customRulesFunction · 0.85
menu_disableFunction · 0.70
menu_switchFunction · 0.70

Tested by

no test coverage detected