[bugfix] 解决右键菜单重复添加报错问题
This commit is contained in:
parent
0620de4fa7
commit
0bdf1bf0df
@ -2,35 +2,41 @@
|
||||
console.clear()
|
||||
console.log("[小墨助手]", "Service Worker init success.")
|
||||
|
||||
/**
|
||||
* 右键菜单
|
||||
*/
|
||||
chrome.contextMenus.create({
|
||||
id: 'bitdance',
|
||||
title: '小墨助手'
|
||||
})
|
||||
|
||||
chrome.contextMenus.create({
|
||||
id: 'bitdance-advanced-search',
|
||||
title: '高级搜索',
|
||||
parentId: 'bitdance',
|
||||
// onclick: function (info) {
|
||||
// }
|
||||
})
|
||||
chrome.contextMenus.onClicked.addListener(function (info) {
|
||||
console.log('当前菜单信息:' + JSON.stringify(info))
|
||||
console.log("[小墨助手]", "高级搜索 已点击菜单")
|
||||
})
|
||||
|
||||
|
||||
// Events must be registered synchronously from the start of the page.
|
||||
chrome.runtime.onInstalled.addListener(() => {
|
||||
console.log("[小墨助手]", "chrome.runtime.onInstalled.")
|
||||
|
||||
// In Chrome, you should create the context menu just once after install/update.
|
||||
// refer: https://stackoverflow.com/questions/64318529/cannot-create-item-with-duplicate-context-menu-id-in-extension
|
||||
|
||||
/**
|
||||
* 右键菜单
|
||||
*/
|
||||
chrome.contextMenus.create({
|
||||
id: 'bitdance',
|
||||
title: '小墨助手'
|
||||
})
|
||||
|
||||
chrome.contextMenus.create({
|
||||
id: 'bitdance-advanced-search',
|
||||
title: '高级搜索',
|
||||
parentId: 'bitdance',
|
||||
// onclick: function (info) {
|
||||
// }
|
||||
})
|
||||
chrome.contextMenus.onClicked.addListener(function (info) {
|
||||
console.log('当前菜单信息:' + JSON.stringify(info))
|
||||
console.log("[小墨助手]", "高级搜索 已点击菜单")
|
||||
})
|
||||
|
||||
chrome.contextMenus.create({
|
||||
"id": "sampleContextMenu",
|
||||
"title": "Sample Context Menu",
|
||||
"contexts": ["selection"]
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
//
|
||||
|
@ -56,7 +56,6 @@ var manifest = {
|
||||
// "automation": {},
|
||||
|
||||
"background": {
|
||||
// "service_worker": "scripts/service_worker/background.js"
|
||||
"service_worker": "background.js"
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user