Chrome: don't open an Options tab for each window

pull/2/head
Deathamns 10 years ago committed by gorhill
parent 04a2486ca9
commit 390733affe

@ -159,61 +159,63 @@ vAPI.tabs.open = function(details) {
active: !!details.active active: !!details.active
}; };
if ( details.tabId ) { if ( !details.tabId ) {
// update doesn't accept index, must use move
chrome.tabs.update(parseInt(details.tabId, 10), _details, function(tab) {
// if the tab doesn't exist
if ( vAPI.lastError() ) {
chrome.tabs.create(_details);
} else if ( details.index !== undefined ) {
chrome.tabs.move(tab.id, {index: details.index});
}
});
} else {
if ( details.index !== undefined ) { if ( details.index !== undefined ) {
_details.index = details.index; _details.index = details.index;
} }
chrome.tabs.create(_details); chrome.tabs.create(_details);
return;
} }
};
if ( details.index === -1 ) { // update doesn't accept index, must use move
vAPI.tabs.get(null, function(tab) { chrome.tabs.update(parseInt(details.tabId, 10), _details, function(tab) {
if ( tab ) { // if the tab doesn't exist
details.index = tab.index + 1; if ( vAPI.lastError() ) {
} else { chrome.tabs.create(_details);
delete details.index; } else if ( details.index !== undefined ) {
chrome.tabs.move(tab.id, {index: details.index});
} }
subWrapper();
}); });
} };
else {
if ( details.index !== -1 ) {
subWrapper(); subWrapper();
return;
} }
};
if ( details.select ) {
chrome.tabs.query({ currentWindow: true }, function(tabs) {
var rgxHash = /#.*/;
// this is questionable
var url = targetURL.replace(rgxHash, '');
var selected = tabs.some(function(tab) {
if ( tab.url.replace(rgxHash, '') === url ) {
chrome.tabs.update(tab.id, { active: true });
return true;
}
});
if ( !selected ) { vAPI.tabs.get(null, function(tab) {
wrapper(); if ( tab ) {
details.index = tab.index + 1;
} else {
delete details.index;
} }
subWrapper();
}); });
} };
else {
if ( !details.select ) {
wrapper(); wrapper();
return;
} }
chrome.tabs.query({}, function(tabs) {
var rgxHash = /#.*/;
// this is questionable
var url = targetURL.replace(rgxHash, '');
var selected = tabs.some(function(tab) {
if ( tab.url.replace(rgxHash, '') === url ) {
chrome.tabs.update(tab.id, { active: true });
chrome.windows.update(tab.windowId, { focused: true });
return true;
}
});
if ( !selected ) {
wrapper();
}
});
}; };
/******************************************************************************/ /******************************************************************************/

Loading…
Cancel
Save