Better error checking
This commit is contained in:
parent
23e19b48d9
commit
7a4ae9da25
|
@ -3,6 +3,10 @@ let bookmarkingTabs = false;
|
|||
|
||||
function createFolder(callback) {
|
||||
chrome.bookmarks.create({'title': 'Autobookmarked Tabs'}, function(folder) {
|
||||
if (chrome.runtime.lastError) {
|
||||
setActionStatus('Error bookmarking tabs', 'error', function() {});
|
||||
return;
|
||||
}
|
||||
chrome.storage.local.set({'bookmarksFolder': folder.id});
|
||||
callback(folder.id);
|
||||
});
|
||||
|
@ -49,12 +53,17 @@ function bookmarkTabs() {
|
|||
setActionStatus('Bookmarking tabs…', 'processing', function() {
|
||||
getOrCreateFolder(function(rootId) {
|
||||
chrome.bookmarks.create({'title': dateString + ' ' + timeString, parentId: rootId}, function(folder) {
|
||||
if (chrome.runtime.lastError) {
|
||||
setActionStatus('Error bookmarking tabs', 'error', function() {});
|
||||
return;
|
||||
}
|
||||
chrome.tabs.query({}, function(tabs) {
|
||||
let remaining = tabs.length;
|
||||
for (let tab of tabs) {
|
||||
chrome.bookmarks.create({'title': tab.title, url: tab.url, parentId: folder.id}, function() {
|
||||
if (chrome.runtime.lastError) {
|
||||
setActionStatus('Error bookmarking tabs', 'error', function() {});
|
||||
return;
|
||||
}
|
||||
|
||||
remaining--;
|
||||
|
|
Loading…
Reference in New Issue