0

我正在尝试开发一些 Chrome 扩展,由可怕的 Google 开发人员指南指导:https ://developer.chrome.com/extensions/contextMenus.html

但我遇到了这个错误:

chrome.contextMenus 不可用:您无权访问此 API。

确保您的 manifest.json 中包含所需的权限或清单属性。

这是我的 manifest.json:

{
    "manifest_version": 2,

    "name": "Data v0.1",
    "description": "This extension makes information handling easier...",
    "version": "0.1",

    "icons": { "16": "16x16.png" },

    "permissions": [
        "contextMenus"
    ],

    "content_scripts": [
        {
            "matches": [ "*://*/*" ],
            "js": [ "data.js" ],
            "run_at": "document_start"
        }
    ],

    "browser_action": {
        "default_icon": "16x16.png"
    },

    "options_page": "options.html"
}

我做错了什么?

4

1 回答 1

0

Old question, but: this API cannot be called from a content script.

If you add a background script, you'll be able to handle chrome.contextMenus

于 2014-11-01T13:52:08.030 回答