const options = {
contexts: ["selection"],
id: 'menu',
title: '新加的菜单:%s',
onclick: chushou,
visible: true,
checked: false
}
chrome.contextMenus.create(options);
5、创建在 链接 上起作用的菜单
通过 contexts: ['link'] 是一个 array 类型的配置选项
button5.onclick = () => {
const options = {
type: 'normal',
contexts: ['link'],
id: '1_5',
title: 'menu on link',
}
chrome.contextMenus.create(options, () => {
alert(`Created Success, id:${options.id}`);
});
}
chrome.contextMenus.remove('menu');
button6.onclick = () => {
chrome.contextMenus.remove('1', () => {
alert('已删除')
});
}