You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 use chrome.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?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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