Google chrome extension 为什么Google Chrome会使有效的WebExtension失效';s manifest.json

Google chrome extension 为什么Google Chrome会使有效的WebExtension失效';s manifest.json,google-chrome-extension,Google Chrome Extension,导入有效的未打包扩展时。 (舱单确认人) 出现此错误,并且扩展未加载 只能选择“浏览器操作”、“页面操作”和“应用程序”中的一个 指定的 清单不包含错误中提到的两个的重复项 manifest.json { "applications": { "gecko": { "id": "addon@example.com", "strict_min_version": "42.0" } }, "background": { "scripts":

导入有效的未打包扩展时。
(舱单确认人)

出现此错误,并且扩展未加载

只能选择“浏览器操作”、“页面操作”和“应用程序”中的一个 指定的

清单不包含错误中提到的两个的重复项

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": "userInterface/browser_action_button/airplay_icon.svg",
    "default_title": "LightDictionary",
    "default_popup": "userInterface/browser_action_button/popup.html"
  },

  "commands": {
    "_execute_browser_action": {
      "suggested_key": {
        "default": "Ctrl+Shift+Y"
      }
    }
  },

  "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": "none",

  "icons": {
    "48": "userInterface/browser_action_button/airplay_icon.svg",
    "96": "userInterface/browser_action_button/airplay_icon.svg"
  },

  "manifest_version": 2,

  "name": "LightDictionary",

  "page_action": {
    "default_icon": {
      "19": "userInterface/browser_action_button/airplay_icon.svg",
      "38": "userInterface/browser_action_button/airplay_icon.svg"
    },
    "default_title": "LightDictionary",
    "default_popup": "userInterface/browser_action_button/popup.html"
  },

  "permissions": ["webNavigation"],

  "version": "0.1",

  "web_accessible_resources": ["images/my-image.png"]
}

我已经在他们的IRC频道上与Mozilla MDN维护人员进行了交谈,我得出结论,所谓的“跨浏览器扩展”manifest.json发布于:

与Chrome不兼容,仅在Firefox浏览器上可用,原因是:

Chrome对清单有严格的检查,Chrome处理清单的方式与Firefox不同。Chrome在采用Firefox支持的技术方面进展缓慢

因此,使清单跨浏览器兼容的唯一方法是

  • 接受
  • 将其加载到Chrome(,打开开发者模式,加载未打包)

  • 检查错误并删除chrome请求的内容

  • 要记住的事情:

    • Chrome不支持.svg格式的图标,这会导致不显示指定的图标。虽然Firefox确实支持svg,但建议不要将svg用于跨浏览器扩展

    进一步的注释如下:

    您只能拥有它在错误中指定的属性之一

    只能指定“浏览器操作”、“页面操作”和“应用程序”中的一个

    json对象中既有浏览器动作属性,也有页面动作属性


    从对象中删除其中一个以修复它。

    这意味着如果有浏览器操作,则不能有页面操作,反之亦然。一般提示-如果扩展适用于所有页面,请使用浏览器操作。如果使用仅限于某些页面-请使用页面操作。