0

I'm getting the following error. The extension is working fine as I want it to but what's with the error?

Extension Error

NoobCoder
  • 189
  • 1
  • 14

2 Answers2

1

Context items persist between extension reloads - something not very obvious.

So you're getting this when this code is executed a second time.

A common pattern is clear-then-register:

chrome.contextMenus.removeAll(function() {
  chrome.contextMenus.create(contextMenuItem);
  // Add more
});

If you're using an Event page (persistent: false background page), you probably don't want to execute that every time the page is woken up; wrap it in chrome.runtime.onStartup or even chrome.runtime.onInstalled (to register once per update).

Xan
  • 74,770
  • 16
  • 179
  • 206
0

Have you added the menu to the permissions-part of your manifest.json? More info can be found here.

Peter Bode
  • 222
  • 1
  • 9
  • The permissions have the following. "permissions": [ "activeTab", "storage", "notifications", "contextMenus" ] – NoobCoder Nov 12 '18 at 14:59
  • @NoobCoder meaby this helps [link](https://stackoverflow.com/questions/19326994/issues-with-content-menu-and-opening-tabs-chrome-extension)? – Peter Bode Nov 12 '18 at 15:06