I have function which take opened tabs and save it into chrome.storage, problem is that I need to execute function chrome.windows.getAll() first, but if my function runs it skips function chrome.windows.getAll() and after whole function it will jump back to function chrome.windows.getAll() and execute it as last.
This is my code:
var new_tabs = [];
chrome.windows.getAll({populate:true},function(windows){
windows.forEach(function(window){
window.tabs.forEach(function(tab){
new_tabs.push(tab.url);
});
});
});
chrome.storage.local.set({'tabs': new_tabs});