简体   繁体   中英

Chrome Extension: Manifest.json include JS in options

Basic question, what is the best way to include javascript on my "options_page" within the manifest.json? Pretty sure I got two errors, how I include the js & the naming/parameters of how I included the page.

Any help would be amazing!!

Below is where I am getting the error:

 {
    "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://*/*"]
    }]
}

您需要从"chrome_style": true,删除逗号"chrome_style": true,

You don't need to include the options script in the manifest. Just declare the html page and add the script as a <script> in your html. Your options page doesn't share a dom with other websites, so it doesn't have such extensive security restrictions.

<script src="options.js"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM