谷歌瀏覽器擴展程序manifest.json參數詳解

  1 {
  2     // Required
  3     "manifest_version": 2,                        // manifest編寫規範版本,目前主流2
  4     "name": "My Extension",                        // 插件名
  5     "version": "versionString",                    // 版本號
  6 
  7     // Recommended
  8     "default_locale": "en",                        // 默認編碼
  9     "description": "A plain text description",     // 插件描述
 10     "icons": {                                    // 插件下載或瀏覽時顯示的圖標,可選多種規格,建議128
 11         "16": "icon16.png",
 12         "48": "icon48.png",
 13         "128": "icon128.png"
 14     },
 15 
 16     // Pick one (or none)
 17     "browser_action": {},                        // 圖標顯示在地址欄右邊,能在全部頁面顯示
 18     "page_action": {},                            // 圖標顯示在地址欄右側(地址欄內),只在特定頁面顯示
 19 
 20     // Optional
 21     "author": "",                                // 插件做者
 22     "automation": true,                            // 開啓自動化
 23     "background": {                                // 可常駐瀏覽器後臺的腳本,能夠鏈接其餘頁面
 24         // Recommended
 25         "persistent": false,
 26         "script": ["background.js"]
 27     },
 28     "background_page": ,
 29     "chrome_settings_overrides": {},            // 覆蓋當前的chrome配置
 30     "chrome_ui_overrides": {                    // 覆蓋當前的chrome界面配置
 31         "bookmarks_ui": {
 32         "remove_bookmark_shortcut": true,
 33         "remove_button": true
 34         }
 35     },
 36     "chrome_url_overrides": {                    // 修改點擊相應動做時返回的頁面連接,只支持bookmarks、history、newtab三個頁面
 37         "bookmarks": "myPage.html",
 38         "history": "myPage.html",
 39         "newtab": "myPage.html"
 40     },
 41     "commands": {                                // 鍵盤觸發插件快捷鍵
 42         "_execute_browser_action": {
 43             "suggested_key": {
 44                 "windows": "Ctrl+Shift+Y",
 45                 "mac": "Command+Shift+Y",
 46                 "chromeos": "Ctrl+Shift+U",
 47                 "linux": "Ctrl+Shift+J"
 48             }
 49          },
 50     },
 51     "content_capabilities": {                                                // 頁面權限
 52         "matches": ["https://*.nyc.corp.google.com/*"],
 53         "permissions": ["unlimitedStorage", "notifications"] 
 54     },
 55     "content_scripts": [{                                                    // 能夠操做頁面元素,不能使用chrome的api
 56         "matches": ["http://www.google.com/*"],
 57         "css": ["mystyles.css"],
 58         "js": ["jquery.js", "myscript.js"]
 59     }],
 60     "content_security_policy": "script-src 'self'; object-src 'self'",        // 安全策略,默認狀況下禁止使用eval或者Function構造函數,以及內聯js,禁止載入外部腳本
 61     "converted_from_user_script": true,                                        // 將用戶腳本轉化爲content script,容許使用GM_* (greasemonkey)方法
 62     "copresence": ,
 63     "current_locale": ,
 64     "devtools_page": "devtools.html",                                        // 在開發中工具中的頁面
 65     "event_rules": [{                                                        // 事件監聽規則及條件
 66         "event": "declarativeContent.onPageChanged",
 67         "actions": [{
 68             "type": "declarativeContent.ShowPageAction"
 69         }],
 70         "conditions": [{
 71             "type": "declarativeContent.PageStateMatcher",
 72             "css": ["video"]
 73         }]
 74     }],
 75     "externally_connectable": {                                                // 哪些外部擴展、應用或網頁能鏈接此插件
 76         "ids": [
 77             "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
 78             "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
 79             "*"                                                                // 容許全部可以使用 "*"
 80         ],
 81         "matches": ["*://*.example.com/*"],
 82         "accepts_tls_channel_id": false
 83     },
 84     "file_browser_handlers": [{                                                // 容許用戶上傳文件,只支持Chrome OS
 85         "id": "upload",
 86         "default_title": "Save to Gallery",                                 // 按鈕文字
 87         "file_filters": [
 88             "filesystem:*.jpg",                                             // 匹配全部文件可用 "filesystem:*.*"
 89             "filesystem:*.jpeg",
 90             "filesystem:*.png"
 91         ]
 92     }],
 93     "file_system_provider_capabilities": {                                    // 容許訪問文件系統,只支持Chrome OS
 94         "configurable": true,
 95         "multiple_mounts": true,
 96         "source": "network"
 97     },
 98     "homepage_url": "http://path/to/homepage",                                // 插件主頁,顯示在chrome擴展工具列表中
 99     "export": {                                                                // 容許其餘組件調用本身的模塊
100         "whitelist": [
101             "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
102             "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
103         ]
104     },
105     "import": [{"id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}],                    // 調用其餘組件的模塊,與其餘組件的export屬性共用
106     "incognito": "spanning or split or not_allowed",                        // 隱身模式
107     "input_components": [                                                    // 輸入管理,鍵盤事件等
108         {
109             "name": "Test IME",
110             "type": "ime",
111             "id": "test",
112             "description": "Test IME",                                        // A user visible description
113             "language": "en-US",                                            // The primary language this IME is used for
114             "layouts": ["us::eng"]                                            // The supported keyboard layouts for this IME
115         }
116     ],
117     "key": "publicKey",                                                        // 自動生成,可不須要
118     "minimum_chrome_version": "versionString",                                // 要求支持的chrome的最低版本
119     "nacl_modules": [{                                                        // 使用native client 模塊
120         "path": "OpenOfficeViewer.nmf",
121         "mime_type": "application/vnd.oasis.opendocument.spreadsheet"
122     }],
123     "oauth2": ,                                                                // 谷歌帳戶相關信息
124     "offline_enabled": true,                                                // 離線使用
125     "omnibox": {                                                            // 搜索關鍵詞推薦
126         "keyword": "aString"
127     },
128     "optional_permissions": ["tabs"],                                        // 運行時權限,非必須權限
129     "options_page": "options.html",                                            // 設置頁,可從擴展工具列表進入
130     "options_ui": {                                                            // 設置頁
131         "chrome_style": true,
132         "page": "options.html"
133     },
134     "permissions": ["tabs"],                                                // 安裝時提示的權限,基本權限
135     "platforms": ,                                                            // 能夠將部分基於平臺的功能文件放入_platform_specific目錄而後列在此項中減小插件體積
136     "plugins": [{ "path": "extension_plugin.dll" }],                        // NPAPI插件
137     "requirements": {                                                        // 安裝前置需求
138         "3D": {
139             "features": ["webgl"]
140         }
141     },
142     "sandbox": [                                                            // 放入沙盒中運行
143         {
144             "pages": [
145                 "page1.html",
146                 "directory/page2.html"
147             ],
148             // content_security_policy is optional.
149             "content_security_policy": "sandbox allow-scripts; script-src https://www.google.com"
150         }
151     ],
152     "short_name": "Short Name",                                                // 短名稱,最長12個字母,如不設置則用name屬性代替
153     "signature": ,
154     "spellcheck": ,                                                            // 拼寫檢查
155     "storage": {                                                            // 描述了各類屬性的type,json格式文件,能在storage.managed API中調用
156         "managed_schema": "schema.json"
157     },
158     "system_indicator": ,                                                    // 實驗性API,只在開發版中實現,已棄用
159     "tts_engine": {                                                            // text to speech
160         "voices": [
161             {
162                 "voice_name": "Alice",
163                 "lang": "en-US",
164                 "gender": "female",
165                 "event_types": ["start", "marker", "end"]
166             },
167             {
168                 "voice_name": "Pat",
169                 "lang": "en-US",
170                 "event_types": ["end"]
171             }
172         ]
173     },                                                        
174     "update_url": "http://myhost.com/mytestextension/updates.xml",            // 插件更新地址
175     "version_name": "aString",                                                // 版本名,和version字段的區別是沒有格式要求,任意字符串
176     "web_accessible_resources": ["images/*.png"]                            // 指定本擴展在注入的目標頁面上所需使用的資源的路徑
177 }

url:https://blog.csdn.net/sysuzjz/article/details/51648163css

相關文章
相關標籤/搜索