externally_connectable 编辑

Experimental

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

TypeObject
MandatoryNo
Example
"externally_connectable": {
  // List of extension IDs that extension wishes to communicate with
  // If "browser_action" is specified but "browser_action.ids" is not,
  // no extensions can communicate with this extension.
  // To match all extension IDs use "*".
  "ids": [
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
    "cccccccccccccccccccccccccccccccc"
  ],
  // Regular expression patterns specifying web pages
  // If "matches" is not specified, no web pages can communicate with
  // this extension
  "matches": [
    "https://example1.com/*",
    "*://*.example2.com/*"
  ]
}

Externally connectable allows extension developer to control which other extensions and web pages can communicate with this extension via runtime.connect() and runtime.sendMessage() message passing. If externally_connectable is not specified, all extensions can communicate with each other but not with web pages.

"ids" attribute

ids enables communication between this extension and other installed extensions specified by extension identifiers. Use the pattern "*" if you wish to communicate with all extensions. 

"matches" attribute

matches enables communication between this extension and the web pages. This is a list of regular expressions for page URLs that you wish to communicate with.

Note: If browser_action is not specified, communication among extensions is still allowed as if browser_action was {"ids": ["*"] }, therefore if you specify browser_action.matches don't forget to add ids if you still want to communicate with other extensions.

Browser compatibility

BCD tables only load in the browser

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:108 次

字数:3414

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文