I've tried to find a solution, but the only thing I found was if a random TabId doesn't exist. But this doesn't solve my problem:
I'm always getting these errors:
Unchecked runtime.lastError while running tabs.get: No tab with id:0
Unchecked runtime.lastError while running tabs.remove: No tab with id:0
My code:
var tabnumber = 0; //the number of tabs in the current window
var tabID = 0; //id of the active tab
function closeBundle(){
getTabnumber();
for(i=0;i<tabnumber;i++){
getTabID();
chrome.tabs.get(tabID , function(tab){ //here is the first problem
insert[i] = tab; //for saving all Tabs in an array
});
chrome.tabs.remove(tabID); //here the second one
}
chache[active] = insert; //I save the insert array in another array
}
function getTabnumber(){
chrome.tabs.query({'currentWindow': true}, function(tabarray){
tabnumber = tabarray.length;
});
}
function getTabID(){
chrome.tabs.query({'currentWindow': true, 'active': true}, function(tabArray){
tabID = tabArray[0].id;
});
}
I don't get it why there is no Tab with this specific id because I used the TabId of the active Tab (with getTabId), doesn't I??
How can I get the right Id of the current Tab or is there another way to store all Tabs of the current window in an array and then close all tabs?
I hope somebody could help me ;)