chrome.bookmarks.create({parentId: nodeId, title: title},function(bmNode) {
chrome.windows.getCurrent(function(window) {
chrome.tabs.getAllInWindow(window.id, function(tabs) {
for(var i=0; i<tabs.length; i++) {
chrome.bookmarks.create({parentId: bmNode.id, title:tabs[i].title,
url:tabs[i].url});
}
});
});
});
Basically I am trying to get all the open tabs in the current window and then create a bookmark folder and add all the tabs to it. It used to work fine till now, suddenly it stopped working. The root folder bookmark is created but the links are not added to the folder.
I know its a lot of nested calls which are asynchronous but how do i make sure all of them execute.
It was a minor thing that i had overlooked. I found out that I was calling “location.reload()” function which was upsetting the whole async callback structure. I removed that and it started working fine now.