manifest.json
代码如下:
{
"name": "我的右键",
"description": "chrome扩展学习---menu使用",
"version": "0.1",
"permissions": ["contextMenus", "tabs"],
"background": {
"scripts": ["menu.js"]
},
"manifest_version": 2
}
menu.js
代码如下:
function genericOnClick(info, tab) {
alert(info.linkUrl);
}
function selectionOnClick(info, tab) {
alert(info.selectionText);
}
var link = chrome.contextMenus.create({"title": "链接地址","contexts":["link"],"onclick":genericOnClick});
var selection = chrome.contextMenus.create({"title": "选中文字","contexts":["selection"],"onclick":selectionOnClick});
更多信息请查看IT技术专栏