How do I send a message from the background to a popup in a Chrome extension everytime a page gets loaded?
问题 I can send a message from a popup to a background via: background.js chrome.runtime.onMessage.addListener( function(request) { alert(request.data.subject); } ); popup.js chrome.runtime.sendMessage({ msg: "something_completed", data: { subject: "Loading...", content: "Just completed!" } }); The alert loads fine BUT I need to do the opposite. I would like the background to send an api call when a page is loaded and send the results of that api call to the popup.js so that it can make changes to