3

when i finish my chrome extension i find an error it is:

 Uncaught TypeError: Cannot call method 'create' of undefined chrome-extension://dpfgkakomehcgdcnigflmkcfngeaamlc/js/background.js:46

injectScript startLiveReload init

i use it is this

mainfest.json "background": { "scripts": ["js/background.js"] }

and background.js like

var readMenuItemId = chrome.contextMenus.create({
  "title" : "阅读模式",
  "type" : "normal",
  contexts : [ "selection" ],
  documentUrlPatterns: ["http://*/*", "https://*/*"],
  "onclick" : genericOnClick
});

i do not know where is wrong

1 Answer 1

12

You need to add permission contextMenus in manifest file in order to use this object:

"permissions": [
    "contextMenus"
],

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.