I have injected content scripts to all frames. I sent a request from background and would like to receive response from all the content scripts (frames that have been injected).
Currently I can only receive one response, how do I receive responses from all content scripts?
content script:
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.bgReq == "windowInfo")
alert("bgreq received : "+ window.location.host);
});
background script:
chrome.runtime.onMessage.addListener(function(sentWords) {
if (sentWords.words == "injection") {
//send request to content scritps
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {bgReq:"windowInfo"});
});
}
});