I have successfully injected content scripts into all frames. I initiated a request from the background script and now I'm looking to receive responses from all the injected content scripts (frames).
However, at the moment I am only able to receive one response. How can I modify my code to receive responses from all content scripts?
Here is the code snippet for the content script:
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.bgReq == "windowInfo")
alert("Received bgreq: "+ window.location.host);
});
And here is the code snippet for the background script:
chrome.runtime.onMessage.addListener(function(sentWords) {
if (sentWords.words == "injection") {
// Send request to content scripts
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {bgReq:"windowInfo"});
});
}
});