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

Function rightClickMenu_

Lanzou-Enhanced.user.js:273–292  ·  view source on GitHub ↗
(list_id_name, menu_id_name_prefix, list_id_name_prefix)

Source from the content-addressed store, hash-verified

271
272 // 右键文件显示菜单,参数:文件/文件夹列表 ID、菜单 ID、菜单 ID前缀
273 function rightClickMenu_(list_id_name, menu_id_name_prefix, list_id_name_prefix) {
274 let list_ = mainframe.document.getElementById(list_id_name);
275 if (!list_) return // 文件/文件夹列表
276 list_.oncontextmenu = function(e){
277 e.preventDefault(); // 屏蔽浏览器自身右键菜单
278 let left = e.pageX - 30; // 右键菜单弹出位置
279 let list_ID = e.target.id;
280 if (e.target.nodeName === 'FONT') {
281 list_ID = e.target.parentNode.parentNode.id
282 } else if(e.target.id === '') {
283 list_ID = e.target.parentNode.id
284 }
285 list_ID = /\d+/.exec(list_ID)
286 if(list_ID.length > 0){
287 mainframe.document.getElementById(menu_id_name_prefix + list_ID[0]).style.cssText='position: absolute !important; left: ' + left + 'px;' // 修改右键菜单弹出位置(X)
288 mainframe.document.getElementById(list_id_name_prefix + list_ID[0]).focus();
289 mainframe.document.getElementById(list_id_name_prefix + list_ID[0]).click();
290 }
291 }
292 }
293
294
295 // 自动显示更多文件(后台页)

Callers 1

rightClickMenuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected