Chrome扩展后台脚本如何与网页服务工作者进行沟通? [英] How can Chrome extension background script communicate with web page service worker?

查看:169
本文介绍了Chrome扩展后台脚本如何与网页服务工作者进行沟通?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的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扩展后台脚本如何与网页服务工作者进行沟通?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆