扩展的清单文件格式

Microsoft Edge 的每个扩展都有一个名为 的 JSON 格式清单文件 manifest.json。 清单文件是扩展的蓝图。 清单文件包括如下信息:

  • 扩展的版本号。
  • 扩展的标题。
  • 扩展运行所需的权限。

清单 V2 已弃用

将清单 V3 用于新代码。 扩展的格式 manifest.json 正在从清单 V2 移动到清单 V3。 此处显示了这两种格式。 若要将清单 V2 扩展迁移到清单 V3,请参阅 将扩展从清单 V2 迁移到 V3

扩展的 manifest.json 格式

以下代码显示了清单 V3 或 V2 包的扩展支持的 manifest.json 字段。

有关每个字段的参考信息,请参阅 清单文件格式 (V3) 然后单击字段上的链接。

{
  // Required
  "manifest_version": 3,
  "name": "My V3 Extension",
  "version": "versionString",

  // Recommended
  "action": {...},
  "default_locale": "en",
  "description": "A plain-text description",
  "icons": {...},

  // Optional
  "action": ...,
  "author": ...,
  "automation": ...,
  "background": {
    // If `background` is included, `service_ worker` is required
    "service_worker": ...
  },
  "chrome_settings_overrides": {...},
  "chrome_url_overrides": {...},
  "commands": {...},
  "content_capabilities": ...,
  "content_scripts": [{...}],
  "content_security_policy": "policyString",
  "converted_from_user_script": ...,
  "current_locale": ...,
  "declarative_net_request": ...,
  "devtools_page": "devtools.html",
  "differential_fingerprint": ...,
  "event_rules": [{...}],
  "externally_connectable": {
    "matches": ["*://*.contoso.com/*"]
  },
  "file_browser_handlers": [...],
  "file_system_provider_capabilities": {
    "configurable": true,
    "multiple_mounts": true,
    "source": "network"
  },
  "homepage_url": "http://path/to/homepage",
  "host_permissions": [...],
  "import": [{"id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}],
  "incognito": "spanning, split, or not_allowed",
  "input_components": ...,
  "key": "publicKey",
  "minimum_chrome_version": "versionString",
  "nacl_modules": [...],
  "natively_connectable": ...,
  "oauth2": ...,
  "offline_enabled": true,
  "omnibox": {
    "keyword": "aString"
  },
  "optional_permissions": ["tabs"],
  "options_page": "options.html",
  "options_ui": {
    "chrome_style": true,
    "page": "options.html"
  },
  "permissions": ["..."],
  "platforms": ...,
  "replacement_web_app": ...,
  "requirements": {...},
  "sandbox": [...],
  "short_name": "Short Name",
  "side_panel": {...},
  "storage": {
    "managed_schema": "schema.json"
  },
  "system_indicator": ...,
  "tts_engine": {...},
  "update_url": "http://path/to/updateInfo.xml",
  "version_name": "aString",
  "web_accessible_resources": [...]
}

manifest.json V3 与 V2 中的更改

V3 V2
"manifest_version": 3, "manifest_version": 2,
"action": {...}, "browser_action": {...},
"action": {...}, "page_action": {...},
删除 "persistent": false,
如果 background 包含 , service_ worker 则是必需的 如果 background 包含 , service_ worker 则 为可选
分为两个不同的键: "permissions": [...], "host_permissions": [...], "permissions": [...],

注意

此页面的部分内容是基于 Google 创建和 共享 的工作进行的修改,并根据 Creative Commons 署名 4.0 国际许可中所述的条款使用。 原始页面 在此处找到。

Creative Commons 许可证 此作品根据 Creative Commons 署名 4.0 国际许可获得许可

另请参阅