MyContextMenu

原生js右键弹出菜单

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/464425/1178359/MyContextMenu.js

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

作者
wish king
版本
0.0.1.20230419170059
创建于
2023-04-19
更新于
2023-04-19
大小
10.7 KB
许可证
暂无

原生js右键弹出菜单
修改自:https://github.com/electerious/basicContext/

在线预览:
https://jsrun.net/k5dKp/embedded/all/light

截图:


使用示例:

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);
});