To tłumaczenie jest niekompletne. Pomóż przetłumaczyć ten artykuł z języka angielskiego.

The manifest.json file is a JSON-formatted file, and is the only file that every extension using WebExtension APIs 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 No No4848 No
author Yes Yes15252 Yes
background Yes Yes24848 Yes
browser_action Yes Yes4855 Yes
chrome_settings_overrides Yes No55 No No
chrome_url_overrides Yes1554 No No
commands Yes No48 No Yes
content_scripts Yes3 Yes484484 Yes3
content_security_policy Yes Yes5486486 Yes
default_locale Yes Yes4848 Yes
description Yes Yes4848 Yes
developer No No5252 Yes
devtools_page Yes No54 No Yes
homepage_url Yes No4848 Yes
icons Yes Yes4848 Yes
incognito Yes No4848 Yes
manifest_version Yes Yes4848 Yes
name Yes Yes4848 Yes
omnibox Yes No52 No Yes
optional_permissions Yes No5555 Yes
options_ui40 No4857277
page_action Yes8 Yes8 948 Yes Yes
permissions Yes Yes4848 Yes
protocol_handlers No No5454 No
short_name Yes Yes4848 Yes
sidebar_action No No54 No Yes
theme Yes No55 No No
version Yes10 Yes4848 Yes
web_accessible_resources Yes Yes4848 Yes

1. This key is mandatory in Microsoft Edge.

2. The 'persistent' property is mandatory.

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

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

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

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

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

8. SVG icons are not supported.

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

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

 

Autorzy i etykiety dokumentu

 Autorzy tej strony: andrewtruongmoz
 Ostatnia aktualizacja: andrewtruongmoz,