Popup.js:
I have a bunch of pages (for example 3), which I get from chrome history according to some logic. Next I put "download links" (one per page, so 3) from this pages to an array, and transfering them to content.js with port.postMessage();
Content.js:
I'm getting that array from popup.js, and next I need to download files. But for some reason script download only last link, and ignore previous 2
Can someone help me with this problem, and explain why it is happening?
popup.js
chrome.tabs.query({currentWindow: true,active: true},
function(tabs)
{
port = chrome.tabs.connect(tabs[0].id,{name: "download"});
port.postMessage(info);
});
content.js
port.onMessage.addListener(function(response)
{
for (var i = 0; i < response.length; i++)
{
document.cookie = cook
window.location = response[i]
}
})