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

 

 {
     // Required
     "manifest_version": 2,                        // manifest編寫規範版本,目前主流2
     "name": "My Extension",                        // 插件名
     "version": "versionString",                    // 版本號
 
     // Recommended
     "default_locale": "en",                        // 默認編碼
     "description": "A plain text description",     // 插件描述
     "icons": {                                    // 插件下載或瀏覽時顯示的圖標,可選多種規格,建議128
         "16": "icon16.png",
         "48": "icon48.png",
         "128": "icon128.png"
     },
 
     // Pick one (or none)
     "browser_action": {},                        // 圖標顯示在地址欄右邊,能在全部頁面顯示
     "page_action": {},                            // 圖標顯示在地址欄右側(地址欄內),只在特定頁面顯示
 
     // Optional
     "author": "",                                // 插件做者
     "automation": true,                            // 開啓自動化
     "background": {                                // 可常駐瀏覽器後臺的腳本,能夠鏈接其餘頁面
         // Recommended
         "persistent": false,
         "script": ["background.js"]
     },
     "background_page": ,
     "chrome_settings_overrides": {},            // 覆蓋當前的chrome配置
     "chrome_ui_overrides": {                    // 覆蓋當前的chrome界面配置
         "bookmarks_ui": {
         "remove_bookmark_shortcut": true,
         "remove_button": true
         }
     },
     "chrome_url_overrides": {                    // 修改點擊相應動做時返回的頁面連接,只支持bookmarks、history、newtab三個頁面
         "bookmarks": "myPage.html",
         "history": "myPage.html",
         "newtab": "myPage.html"
     },
     "commands": {                                // 鍵盤觸發插件快捷鍵
         "_execute_browser_action": {
             "suggested_key": {
                 "windows": "Ctrl+Shift+Y",
                 "mac": "Command+Shift+Y",
                 "chromeos": "Ctrl+Shift+U",
                 "linux": "Ctrl+Shift+J"
             }
          },
     },
     "content_capabilities": {                                                // 頁面權限
         "matches": ["https://*.nyc.corp.google.com/*"],
         "permissions": ["unlimitedStorage", "notifications"] 
     },
     "content_scripts": [{                                                    // 能夠操做頁面元素,不能使用chrome的api
         "matches": ["http://www.google.com/*"],
         "css": ["mystyles.css"],
         "js": ["jquery.js", "myscript.js"]
     }],
     "content_security_policy": "script-src ‘self‘; object-src ‘self‘",        // 安全策略,默認狀況下禁止使用eval或者Function構造函數,以及內聯js,禁止載入外部腳本
     "converted_from_user_script": true,                                        // 將用戶腳本轉化爲content script,容許使用GM_* (greasemonkey)方法
     "copresence": ,
     "current_locale": ,
     "devtools_page": "devtools.html",                                        // 在開發中工具中的頁面
     "event_rules": [{                                                        // 事件監聽規則及條件
         "event": "declarativeContent.onPageChanged",
         "actions": [{
             "type": "declarativeContent.ShowPageAction"
         }],
         "conditions": [{
             "type": "declarativeContent.PageStateMatcher",
             "css": ["video"]
         }]
     }],
     "externally_connectable": {                                                // 哪些外部擴展、應用或網頁能鏈接此插件
         "ids": [
             "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
             "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
             "*"                                                                // 容許全部可以使用 "*"
         ],
         "matches": ["*://*.example.com/*"],
         "accepts_tls_channel_id": false
     },
     "file_browser_handlers": [{                                                // 容許用戶上傳文件,只支持Chrome OS
         "id": "upload",
         "default_title": "Save to Gallery",                                 // 按鈕文字
         "file_filters": [
             "filesystem:*.jpg",                                             // 匹配全部文件可用 "filesystem:*.*"
             "filesystem:*.jpeg",
             "filesystem:*.png"
         ]
     }],
     "file_system_provider_capabilities": {                                    // 容許訪問文件系統,只支持Chrome OS
         "configurable": true,
         "multiple_mounts": true,
         "source": "network"
     },
     "homepage_url": "http://path/to/homepage",                                // 插件主頁,顯示在chrome擴展工具列表中
     "export": {                                                                // 容許其餘組件調用本身的模塊
         "whitelist": [
             "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
             "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
         ]
     },
     "import": [{"id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}],                    // 調用其餘組件的模塊,與其餘組件的export屬性共用
     "incognito": "spanning or split or not_allowed",                        // 隱身模式
     "input_components": [                                                    // 輸入管理,鍵盤事件等
         {
             "name": "Test IME",
             "type": "ime",
             "id": "test",
             "description": "Test IME",                                        // A user visible description
             "language": "en-US",                                            // The primary language this IME is used for
             "layouts": ["us::eng"]                                            // The supported keyboard layouts for this IME
         }
     ],
     "key": "publicKey",                                                        // 自動生成,可不須要
     "minimum_chrome_version": "versionString",                                // 要求支持的chrome的最低版本
     "nacl_modules": [{                                                        // 使用native client 模塊
         "path": "OpenOfficeViewer.nmf",
         "mime_type": "application/vnd.oasis.opendocument.spreadsheet"
     }],
     "oauth2": ,                                                                // 谷歌帳戶相關信息
     "offline_enabled": true,                                                // 離線使用
     "omnibox": {                                                            // 搜索關鍵詞推薦
         "keyword": "aString"
     },
     "optional_permissions": ["tabs"],                                        // 運行時權限,非必須權限
     "options_page": "options.html",                                            // 設置頁,可從擴展工具列表進入
     "options_ui": {                                                            // 設置頁
         "chrome_style": true,
         "page": "options.html"
     },
     "permissions": ["tabs"],                                                // 安裝時提示的權限,基本權限
     "platforms": ,                                                            // 能夠將部分基於平臺的功能文件放入_platform_specific目錄而後列在此項中減小插件體積
     "plugins": [{ "path": "extension_plugin.dll" }],                        // NPAPI插件
     "requirements": {                                                        // 安裝前置需求
         "3D": {
             "features": ["webgl"]
         }
     },
     "sandbox": [                                                            // 放入沙盒中運行
         {
             "pages": [
                 "page1.html",
                 "directory/page2.html"
             ],
             // content_security_policy is optional.
             "content_security_policy": "sandbox allow-scripts; script-src https://www.google.com"
         }
     ],
     "short_name": "Short Name",                                                // 短名稱,最長12個字母,如不設置則用name屬性代替
     "signature": ,
     "spellcheck": ,                                                            // 拼寫檢查
     "storage": {                                                            // 描述了各類屬性的type,json格式文件,能在storage.managed API中調用
         "managed_schema": "schema.json"
     },
     "system_indicator": ,                                                    // 實驗性API,只在開發版中實現,已棄用
     "tts_engine": {                                                            // text to speech
         "voices": [
             {
                 "voice_name": "Alice",
                 "lang": "en-US",
                 "gender": "female",
                 "event_types": ["start", "marker", "end"]
             },
             {
                 "voice_name": "Pat",
                 "lang": "en-US",
                 "event_types": ["end"]
             }
         ]
     },                                                        
     "update_url": "http://myhost.com/mytestextension/updates.xml",            // 插件更新地址
     "version_name": "aString",                                                // 版本名,和version字段的區別是沒有格式要求,任意字符串
     "web_accessible_resources": ["images/*.png"]                            // 指定本擴展在注入的目標頁面上所需使用的資源的路徑
 }
相關文章
相關標籤/搜索