Chrome扩展:Manifest.json在选项中包含JS

时间:2017-07-15 12:33:47

标签: javascript json google-chrome

基本问题,在manifest.json中我的“options_page”中包含javascript的最佳方法是什么?很确定我有两个错误,我如何包含js& amp;我如何包含页面的命名/参数。

任何帮助都会很棒!!

以下是我收到错误的地方:

 {
    "name": " name of app",
    "version": "0.1",
    "description": "app stuff",
    "background": {
        "page": "background.html"
    },
    "manifest_version": 2,

    "browser_action": {
        "name": "Manipulate DOM",
        "icons": ["icon.png"],
        "default_icon": "icon.png"
    },

    "options_ui": {
        // Required.
        "page": "options.html",

        "js": "options.js", // the file i'm trying to add (for fun)

        "chrome_style": true,

    }, //where chrome keeps flagging the error. 

    "content_scripts": [{
        "js": ["jquery-2.0.2.min.js", "background.js"],
        "css": ["customStyles.css"],
        "matches": ["http://*/*", "https://*/*"]
    }]
}

2 个答案:

答案 0 :(得分:0)

您需要从"chrome_style": true,

中删除逗号

答案 1 :(得分:0)

您不需要在清单中包含选项脚本。只需声明html页面并在html中将脚本添加为<script>即可。您的选项页面与其他网站没有共享dom,因此它没有如此广泛的安全限制。

<script src="options.js"></script>
相关问题