001_manifest.json手册

manifest.json 是一个 JSON 格式的文件,是每个 WebExtension必须包含的唯一文件。

使用manifest.json,您可以指定扩展名的基本元数据,如名称和版本,还可以指定扩展功能的各个方面,例如后台脚本,内容脚本和浏览器操作。

通过使用 manifest.json,你可以在你的扩展中制定基本元数据,例如 name 和 version,并且也可以制定你扩展的功能,例如:后台脚本,内容脚本和浏览器行为。

支持的 manifest.json键如下所示:

支持的 manifest.json键如下所示:

"manifest_version",``"version",和 "name" 是唯一的强制性键。如果 "_locales" 目录存在的话,"default_locale" 也必须相应存在,否则不应存在。Google Chrome 不支持 "applications" , 而在Firefox 48之前的Firefox中是必须的。

快速语法示例

{

    "applications": {
      "gecko": {
        "id": "addon@example.com",
          "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": "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"]

}
原文地址:https://www.cnblogs.com/jaycethanks/p/12186051.html