Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

manifest.json

我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译!

The manifest.json file is a JSON-formatted file, and is the only file that every WebExtension must contain.

Using manifest.json, you specify basic metadata about your extension such as the name and version, and can also specify aspects of your extension's functionality, such as background scripts, content scripts, and browser actions.

Supported manifest.json keys are listed below:

 

"manifest_version", "version", and "name" are the only mandatory keys. "default_locale" must be present if the "_locales" directory is present and must be absent otherwise. "applications" is not supported in Google Chrome, and is mandatory in Firefox before Firefox 48.

Quick syntax example for manifest.json:

{

    "applications": {
      "gecko": {
        "id": "[email protected]",
          "strict_min_version": "42.0",
          "strict_max_version": "50.*",
          "update_url": "https://example.com/updates.json"
      }
    },

    "background": {
        "scripts": ["jquery.js", "my-background.js"],
        "page": "my-background.html"
    },

    "browser_action": {
      "default_icon": {
        "19": "button/geo-19.png",
        "38": "button/geo-38.png"
      },
      "default_title": "Whereami?",
      "default_popup": "popup/geo.html"
    },

    "commands": {
      "toggle-feature": {
        "suggested_key": {
          "default": "Ctrl+Shift+Y",
          "linux": "Ctrl+Shift+U"
        },
        "description": "Send a 'toggle-feature' event"
      }
    },

    "content_security_policy": "script-src 'self' https://example.com; object-src 'self'",

    "content_scripts": [
      {
        "exclude_matches": ["*://developer.mozilla.org/*"],
        "matches": ["*://*.mozilla.org/*"],
        "js": ["borderify.js"]
      }
    ],

    "default_locale": "en",

    "description": "...",

    "icons": {
      "48": "icon.png",
      "96": "[email protected]"
    },

    "manifest_version": 2,

    "name": "...",

    "page_action": {
      "default_icon": {
        "19": "button/geo-19.png",
        "38": "button/geo-38.png"
      },
      "default_title": "Whereami?",
      "default_popup": "popup/geo.html"
    },

    "permissions": ["webNavigation"],

    "version": "0.1",

    "web_accessible_resources": ["images/my-image.png"]

}

 

文档标签和贡献者

 此页面的贡献者: Standard8, wbamberg, evilpie, erxin, kmaglione
 最后编辑者: Standard8,