2017-07-15 76 views
0

基本問題,在manifest.json中我的「options_page」中包含javascript的最佳方式是什麼?很確定我有兩個錯誤,我如何包含我包含該頁面的命名/參數的js &。Chrome擴展程序:Manifest.json包含選項中的JS

任何幫助將是驚人的!

下面是我在哪裏得到的錯誤:

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

回答

0

你需要從"chrome_style": true,

0

刪除逗號你並不需要包括在清單中選擇腳本。只需聲明html頁面並將腳本作爲<script>添加到您的html中。您的選項頁面不會與其他網站共享,所以它沒有如此廣泛的安全限制。

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