### Manifest文件格式
在扩展根目录新建 **manifest.json**
#### 字段摘要
下面的代码显示了扩展支持的表现领域,具有链接到讨论每个字段的页面。
~~~
{
// 必须的字段
"manifest_version": 2, //Chrome18以上设置为2
"name": "我的扩展", // 扩展名称,扩展管理里显示的名称
"version": "1.0.0", // 扩展版本
// 非必需,但推荐设置
"default_locale": "zh", // 默认语言:[en,zh]
"description": "这是一个测试扩展,用来学习的", // 扩展介绍,扩展管理里显示的名称
"icons": { // 扩展图标,安装时和扩展管理里显示
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
// 地址栏右侧显示的信息. browser_action和page_action设置一个或不设置
"browser_action": {
"default_icon" : {
"19": "images/icon19.png",
"38": "images/icon38.png"
},
"default_title": "测试扩展",
"default_popup": "popup.html"
},
"page_action": {
"default_icon" : {
"19": "images/icon19.png",
"38": "images/icon38.png"
},
"default_title": "测试扩展",
"default_popup": "popup.html"
},
// 可选的
"author": "热心群众",
"automation": false // 自动启用或禁用扩展
"background": {
"page": "background.html",//注入网页到网页
"scripts": [ //注入脚本到网页
"background.js"
],
// 权限列表,推荐设置
"persistent": [
"activeTab",
"alarms",
"background",
"bookmarks"
]
},
"background_page": "background.html",
"chrome_settings_overrides": {...},
"chrome_ui_overrides": {
"bookmarks_ui": {
"remove_bookmark_shortcut": true,
"remove_button": true
}
},
"chrome_url_overrides": {...},
"commands": {...},
"content_capabilities": ...,
"content_scripts": [{...}],
"content_security_policy": "policyString",
"converted_from_user_script": ...,
"current_locale": ...,
"devtools_page": "devtools.html",
"event_rules": [{...}],
"externally_connectable": {
"matches": ["*://*.example.com/*"]
},
"file_browser_handlers": [...],
"file_system_provider_capabilities": {
"configurable": true,
"multiple_mounts": true,
"source": "network"
},
"homepage_url": "http://path/to/homepage",
"import": [{"id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}],
"incognito": "spanning, split, or not_allowed",
"input_components": ...,
"key": "publicKey",
"minimum_chrome_version": "versionString",
"nacl_modules": [...],
"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": ...,
"plugins": [...],
"requirements": {...},
"sandbox": [...],
"short_name": "Short Name",
"signature": ...,
"spellcheck": ...,
"storage": {
"managed_schema": "schema.json"
},
"system_indicator": ...,
"tts_engine": {...},
"update_url": "http://path/to/updateInfo.xml",
"version_name": "aString",
"web_accessible_resources": [...]
}
~~~