Skip to content

Commit

Permalink
#56 fix: complain about already existing menu items
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Feb 6, 2024
1 parent f923d0f commit d5f71bf
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src-bex/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,27 +374,31 @@ chrome.storage.onChanged.addListener(function () {
loadSettings();
});

const mainMenu = chrome.contextMenus.create({
"id": "mainMenu-root",
"title": "QOwnNotes", "contexts": ["page"]
});
// Make sure old context menus are removed before creating new ones in case
// of the background script being reloaded
chrome.contextMenus.removeAll(() => {
const mainMenu = chrome.contextMenus.create({
"id": "mainMenu-root",
"title": "QOwnNotes", "contexts": ["page"]
});

chrome.contextMenus.create({
"id": "mainMenu-sendPageToQOwnNotes",
"title": getLocale('sendPageToQOwnNotes'), "contexts": ["page"],
"parentId": mainMenu
});
chrome.contextMenus.create({
"id": "mainMenu-sendPageToQOwnNotes",
"title": getLocale('sendPageToQOwnNotes'), "contexts": ["page"],
"parentId": mainMenu
});

chrome.contextMenus.create({
"id": "mainMenu-createScreenshotNote",
"title": getLocale('createScreenshotNote'), "contexts": ["page"],
"parentId": mainMenu
});
chrome.contextMenus.create({
"id": "mainMenu-createScreenshotNote",
"title": getLocale('createScreenshotNote'), "contexts": ["page"],
"parentId": mainMenu
});

chrome.contextMenus.create({
"id": "mainMenu-sendSelectionToQOwnNotes",
"title": getLocale('sendSelectionToQOwnNotes'), "contexts": ["selection"],
"parentId": null
chrome.contextMenus.create({
"id": "mainMenu-sendSelectionToQOwnNotes",
"title": getLocale('sendSelectionToQOwnNotes'), "contexts": ["selection"],
"parentId": null
});
});

chrome.contextMenus.onClicked.addListener(function(info, tab) {
Expand Down

0 comments on commit d5f71bf

Please sign in to comment.