Esta tradução está incompleta. Por favor, ajude a traduzir este artigo.

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.

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 and Firefox for Android.

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
applications No151

48

481

48

481

No
author Yes1425252 Yes
background Yes1434848 Yes
browser_action Yes4144855 Yes4
chrome_settings_overrides Yes No55 No No
chrome_url_overrides Yes No54 No No
commands Yes No48 No Yes
content_scripts Yes514486486 Yes5
content_security_policy Yes147488488 Yes
default_locale Yes144848 Yes
description Yes144848 Yes
developer No No5252 Yes
devtools_page Yes No54 No Yes
externally_connectable Yes No No9 No Yes
homepage_url Yes No4848 Yes
icons Yes144848 Yes
incognito Yes No4848 Yes
manifest_version Yes144848 Yes
name Yes144848 Yes
omnibox Yes No52 No Yes
optional_permissions Yes No5555 Yes
options_page Yes14 No No15
options_ui40 No48572710
page_action

Yes11 12

4913

1411 1448 Yes Yes11 12
permissions Yes144848 Yes
protocol_handlers No No5454 No
short_name Yes144848 Yes
sidebar_action No No54 No30
theme Yes No55 No No
version Yes15144848 Yes
version_name Yes No No No Yes
web_accessible_resources Yes144848 Yes

1. Supported as browser_specific_settings.

2. This key is mandatory in Microsoft Edge.

3. The 'persistent' property is mandatory.

4. If an extension defines a browser action, it is not allowed to define a page action as well.

5. Content scripts are not applied to tabs already open when the extension is loaded.

6. Content scripts won't be injected into empty iframes at 'document_start' even if you specify that value in 'run_at'.

7. Only the default content security policy is supported: "script-src 'self'; object-src 'self';".

8. Firefox does not support 'http://127.0.0.1' or 'http://localhost' as script sources: they must be served over HTTPS.

9. See bug 1319168.

10. Options pages are always opened in a separate browser tab.

11. SVG icons are not supported.

12. If an extension defines a page action, it is not allowed to define a browser action as well.

13. Since Chrome 49, page actions are displayed on the toolbar, rather than in the address bar.

14. 'default_icon' must be an object, with explicit sizes.

15. Valid Chrome versions are a subset of valid Firefox versions.

Example

Quick syntax example for manifest.json:

{
  "applications": {
    "gecko": {
      "id": "addon@example.com",
      "strict_min_version": "42.0"
    }
  },

  "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": "icon@2x.png"
  },

  "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"]
}

 

Etiquetas do documento e colaboradores

Colaboradores desta página: wbamberg
Última atualização por: wbamberg,