清单文件格式

每一个扩展程序、可安装的网络应用以及主题背景都有一个 JSON 格式的清单文件,名为 manifest.json,提供重要信息。

字段概述

如下代码展示了支持的清单文件字段,以及讨论每一个字段的链接。只有 name 和 version 字段是必需的。

  1. {
  2. // 必选
  3. "manifest_version": 2,
  4. "name": "我的扩展程序",
  5. "version": "版本字符串",
  6. // 推荐
  7. "default_locale": "en",
  8. "description": "纯文本描述",
  9. "icons": {...},
  10. // 选择某一个(或者无)
  11. "browser_action": {...},
  12. "page_action": {...},
  13. // 可选
  14. "author": ...,
  15. "background": {
  16. // 推荐
  17. "persistent": false
  18. },
  19. "background_page": ...,
  20. "chrome_settings_overrides": ...,
  21. "chrome_url_overrides": {...},
  22. "commands": {
  23. "global": ...
  24. },
  25. "content_pack": ...,
  26. "content_scripts": [{...}],
  27. "content_security_policy": "策略字符串",
  28. "converted_from_user_script": ...,
  29. "current_locale": ...,
  30. "devtools_page": ...,
  31. "externally_connectable": {
  32. "matches": ["*://*.example.com/*"]
  33. },
  34. "file_browser_handlers": [...],
  35. "homepage_url": "http://path/to/homepage",
  36. "import": ...,
  37. "incognito": "spanning 或 split",
  38. "input_components": ...,
  39. "key": "公钥",
  40. "minimum_chrome_version": "版本字符串",
  41. "nacl_modules": [...],
  42. "oauth2": ...,
  43. "offline_enabled": true,
  44. "omnibox": {
  45. "keyword": "aString"
  46. },
  47. "optional_permissions": ...,
  48. "options_page": "aFile.html",
  49. "page_actions": ...,
  50. "permissions": [...],
  51. "platforms": ...,
  52. "plugins": [...],
  53. "requirements": {...},
  54. "sandbox": [...],
  55. "script_badge": ...,
  56. "short_name": "短名称",
  57. "signature": ...,
  58. "spellcheck": ...,
  59. "storage": {
  60. "managed_schema": "schema.json"
  61. },
  62. "system_indicator": ...,
  63. "tts_engine": ...,
  64. "update_url": "http://path/to/updateInfo.xml",
  65. "web_accessible_resources": [...]
  66. }