Diese Übersetzung ist unvollständig. Bitte helfen Sie, diesen Artikel aus dem Englischen zu übersetzen.

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 Nein Nein4848 Nein
author Ja Ja15252 Ja
background Ja Ja24848 Ja
browser_action Ja Ja4855 Ja
chrome_settings_overrides Ja Nein55 Nein Nein
chrome_url_overrides Ja1554 Nein Nein
commands Ja Nein48 Nein Ja
content_scripts Ja3 Ja484484 Ja3
content_security_policy Ja Ja5486486 Ja
default_locale Ja Ja4848 Ja
description Ja Ja4848 Ja
developer Nein Nein5252 Ja
devtools_page Ja Nein54 Nein Ja
homepage_url Ja Nein4848 Ja
icons Ja Ja4848 Ja
incognito Ja Nein4848 Ja
manifest_version Ja Ja4848 Ja
name Ja Ja4848 Ja
omnibox Ja Nein52 Nein Ja
optional_permissions Ja Nein5555 Ja
options_ui40 Nein4857277
page_action Ja8 Ja8 948 Ja Ja
permissions Ja Ja4848 Ja
protocol_handlers Nein Nein5454 Nein
short_name Ja Ja4848 Ja
sidebar_action Nein Nein54 Nein Ja
theme Ja Nein55 Nein Nein
version Ja10 Ja4848 Ja
web_accessible_resources Ja Ja4848 Ja

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

 

Schlagwörter des Dokuments und Mitwirkende

 Mitwirkende an dieser Seite: andrewtruongmoz
 Zuletzt aktualisiert von: andrewtruongmoz,