reuse openURL so that the opener tab id is set
This commit is contained in:
parent
18265b94c6
commit
367ae56047
|
@ -12,8 +12,6 @@
|
||||||
activateTab
|
activateTab
|
||||||
download
|
download
|
||||||
findExistingTab
|
findExistingTab
|
||||||
getActiveTab
|
|
||||||
isTabReplaceable
|
|
||||||
openURL
|
openURL
|
||||||
*/ // toolbox.js
|
*/ // toolbox.js
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -74,7 +72,7 @@ addAPI(/** @namespace API */ {
|
||||||
if (options) {
|
if (options) {
|
||||||
url += '#stylus-options';
|
url += '#stylus-options';
|
||||||
}
|
}
|
||||||
let tab = await findExistingTab({
|
const tab = await findExistingTab({
|
||||||
url,
|
url,
|
||||||
currentWindow: null,
|
currentWindow: null,
|
||||||
ignoreHash: true,
|
ignoreHash: true,
|
||||||
|
@ -87,10 +85,7 @@ addAPI(/** @namespace API */ {
|
||||||
}
|
}
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
tab = await getActiveTab();
|
return openURL({url, ignoreExisting: true}).then(activateTab); // activateTab unminimizes the window
|
||||||
return isTabReplaceable(tab, url)
|
|
||||||
? activateTab(tab, {url})
|
|
||||||
: browser.tabs.create({url}).then(activateTab); // activateTab unminimizes the window
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -179,6 +179,7 @@ async function findExistingTab({url, currentWindow, ignoreHash = true, ignoreSea
|
||||||
* @param {Boolean} [_.active=true] `true` to activate the tab
|
* @param {Boolean} [_.active=true] `true` to activate the tab
|
||||||
* @param {Boolean|null} [_.currentWindow=true] `null` to check all windows
|
* @param {Boolean|null} [_.currentWindow=true] `null` to check all windows
|
||||||
* @param {chrome.windows.CreateData} [_.newWindow] creates a new window with these params if specified
|
* @param {chrome.windows.CreateData} [_.newWindow] creates a new window with these params if specified
|
||||||
|
* @param {boolean} [_.ignoreExisting] specify to skip findExistingTab
|
||||||
* @returns {Promise<chrome.tabs.Tab>} Promise -> opened/activated tab
|
* @returns {Promise<chrome.tabs.Tab>} Promise -> opened/activated tab
|
||||||
*/
|
*/
|
||||||
async function openURL({
|
async function openURL({
|
||||||
|
@ -188,11 +189,12 @@ async function openURL({
|
||||||
active = true,
|
active = true,
|
||||||
currentWindow = true,
|
currentWindow = true,
|
||||||
newWindow,
|
newWindow,
|
||||||
|
ignoreExisting,
|
||||||
}) {
|
}) {
|
||||||
if (!url.includes('://')) {
|
if (!url.includes('://')) {
|
||||||
url = chrome.runtime.getURL(url);
|
url = chrome.runtime.getURL(url);
|
||||||
}
|
}
|
||||||
let tab = await findExistingTab({url, currentWindow});
|
let tab = !ignoreExisting && await findExistingTab({url, currentWindow});
|
||||||
if (tab) {
|
if (tab) {
|
||||||
return activateTab(tab, {
|
return activateTab(tab, {
|
||||||
index,
|
index,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user