How do I send a message from service worker to content script #740
Unanswered
callmekatootie
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want the service worker to initiate the message - not to send a message AFTER receiving one from the content script.
The documentation talks about using Ports to achieve a 2 way communication b/w background service worker and content script, but the examples seem to indicate that the service worker can respond only to an incoming request.
What if there's no request? How does the service worker send a message in such a case?
My use case - I want to use
chrome.alarms
API to send a message periodically to my content script. Specifically, I want to trigger a function in my content script periodically.I tried to use
setInterval()
in my content script, but that was not very reliable and I was suggested to usechrome.alarms
api instead - but I can call this only from the service worker.To sum it up, I am basically looking to invoke a function in a content script using chrome.alarms API from my service worker. How do I go about it?
Beta Was this translation helpful? Give feedback.
All reactions