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 Nein1514848 Nein
author Ja1425252 Ja
background Ja1434848 Ja
browser_action Ja4144855 Ja4
chrome_settings_overrides Ja Nein55 Nein Nein
chrome_url_overrides Ja1554 Nein Nein
commands Ja Nein48 Nein Ja
content_scripts Ja514486486 Ja5
content_security_policy Ja147488488 Ja
default_locale Ja144848 Ja
description Ja144848 Ja
developer Nein Nein5252 Ja
devtools_page Ja Nein54 Nein Ja
homepage_url Ja Nein4848 Ja
icons Ja144848 Ja
incognito Ja Nein4848 Ja
manifest_version Ja144848 Ja
name Ja144848 Ja
omnibox Ja Nein52 Nein Ja
optional_permissions Ja Nein5555 Ja
options_page Ja14 Nein Nein15
options_ui40 Nein4857279
page_action

Ja10 11

4912

1410 1348 Ja Ja10 11
permissions Ja144848 Ja
protocol_handlers Nein Nein5454 Nein
short_name Ja144848 Ja
sidebar_action Nein Nein54 Nein30
theme Ja Nein55 Nein Nein
version Ja14144848 Ja
version_name Ja Nein Nein Nein Ja
web_accessible_resources Ja144848 Ja

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. Options pages are always opened in a separate browser tab.

10. SVG icons are not supported.

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

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

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

14. 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: DaysieDuck, andrewtruongmoz
Zuletzt aktualisiert von: DaysieDuck,