问题描述
我们的webapp注册了一个服务工作者。我们也有一个Chrome扩展。我们需要的是将服务工作人员的消息发送到扩展程序,而无需打开Web应用程序。我们目前的解决方案是在服务工作者中请求一些URL,并使用将其捕获到扩展的后台脚本中, webRequest
- chrome.webRequest.onBeforeRequest.addListener
。它可以工作,但它看起来非常不标准。
(来自wOxxOm的评论,因为他讨厌回答任何地方, p>
您的解决方案与任何解决方案一样好 - 在添加更直接的支持之前,根据。
Our webapp registers a service worker. We also have a Chrome extension. What we need is to send messages from service worker to the extension without having the webapp open. What is the right approach to do that?
Our current solution is requesting some URL in the service worker and capturing it in the extension's background script using webRequest
- chrome.webRequest.onBeforeRequest.addListener
. It works but it looks pretty much nonstandardly.
(from wOxxOm's comment, since he hates answering anywhere but in comments)
Your solution is as good as any - before more straightforward support is added, as per this feature request.
这篇关于Chrome扩展后台脚本如何与网页服务工作者进行沟通?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!