擴展名的指令清單檔格式

Microsoft Edge 的每個擴充功能都有 JSON 格式的指令清單檔,名為 manifest.json。 指令清單檔是延伸模組的藍圖。 指令清單檔案包含下列資訊:

  • 擴充功能的版本號碼。
  • 延伸模組的標題。
  • 執行擴充功能所需的許可權。

指令清單 V2 已被取代

針對新的程式代碼使用指令清單 V3。 擴充功能的 manifest.json 格式會從指令清單 V2 移至指令清單 V3。 這兩種格式如下所示。 若要將指令清單 V2 擴充功能移轉至指令清單 V3,請參閱 將擴充功能從指令清單 V2 移轉至 V3

擴充功能的manifest.json格式

下列程式代碼顯示針對指令清單 V3 或 V2 套件,在 manifest.json 中支援擴充功能的欄位。

如需每個欄位的參考資訊,請參閱 Chrome Extensions>Reference 中的指令清單檔格式,然後按下字段上的連結。

{
  // 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 Attribution 4.0 國際授權中所述的條款使用。 您可以 在這裡找到原始頁面。

Creative Commons 授權 此工作是根據 Creative Commons Attribution 4.0 International License 授權