MyContextMenu

原生js右键弹出菜单

目前為 2023-04-19 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/464425/1178349/MyContextMenu.js

作者
wish king
版本
0.0.1.20230419170059
建立日期
2023-04-19
更新日期
2023-04-19
尺寸
10.7 KB
授權條款
未知

原生js右键弹出菜单

如图:


使用示例:

const clicked = function(e) {
    console.log(e.target.innerHTML);
}
document.querySelector('.my-context-menu-btn').addEventListener('contextmenu', function(e){
    const items = [
        { title: '新标签打开链接', extAttr: "data-name='new-blank'", fn: clicked },
        { },
        { title: '复制链接地址', extAttr: "data-name='copy-link'", fn: clicked },
        { title: '复制选中的文本', extAttr: "data-name='copy-text'", fn: clicked, disabled: true },
        { title: '复制响应数据', extAttr: "data-name='copy-response'", fn: clicked},
        { },
        { title: '复制为cURL格式', extAttr: "data-name='copy-curl'", fn: clicked},
        { title: '复制为fetch格式', extAttr: "data-name='copy-fetch'", fn: clicked},
        { title: '复制为await格式', extAttr: "data-name='copy-await'", fn: clicked},
        { title: '复制为xhr格式', extAttr: "data-name='copy-xhr'", fn: clicked},
        { title: '复制为分享链接', extAttr: "data-name='copy-share'", fn: clicked},
        { },
        { title: '删除该请求', extAttr: "data-name='del-request'", fn: clicked},
        { title: '删除所有请求', extAttr: "data-name='del-all-request'", fn: clicked }
    ]
    basicContext.show(items, e);
});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址