问题描述
我需要将仅适用于Chrome打包应用程序(可访问syncFileSystem)的功能和仅在Chrome扩展程序中提供的功能(将脚本注入第三方网站)结合使用。
看起来,打包的应用程序和扩展程序都无法实现这两种功能,所以我现在正在考虑尝试使用单独的打包应用程序来实现我的目标和扩展程序进行通信。
我看到解释了两个扩展如何通过 chrome.runtime.onMessageExternal.addListener
和 chrome.runtime.sendMessage $ c $ b>
$ b
是的,这是可能的。链接文档中的代码示例适用于应用程序和扩展的任意组合。
表示:
Messaging在扩展程序和应用程序中的工作方式都是相同的,它们似乎完全兼容;只需使用目标扩展程序或应用程序的ID即可。如果您查看,您会看到它与扩展版本相同。
I need to combine functionality available only in a Chrome packaged app (access to syncFileSystem) and functionality available only in a Chrome extension (injecting a script into a 3rd party website).
It seems that neither a packaged app nor an extension can achieve both these things, so I'm now considering trying to achieve what I'm after with a separate packaged app and extension communicating.
I see that Chrome's documentation explains how two extensions can communicate via chrome.runtime.onMessageExternal.addListener
and chrome.runtime.sendMessage
, but nothing about packaged apps and extensions communicating.
Yes, that is possible. The code sample in the documentation you linked works for any combination of app and extension.
The extension documentation for chrome.runtime.sendMessage
says:
Messaging works the same in both extensions and apps, and they seem to be fully compatible; simply use the ID for the destination extension or app. If you look at the docs for the app version of chrome.runtime.sendMessage
, you'll see that it is identical to the extension version.
这篇关于在Chrome打包的应用和Chrome扩展之间进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!