Merge pull request #171 from idlewan/background-adjacent-tabs
Open adjacent tabs and background tabsjh-changes
commit
89d6afecfd
10 changed files with 46 additions and 12 deletions
@ -1,9 +1,21 @@ |
||||
const openNewTab = (url, openerTabId) => { |
||||
return browser.tabs.create({ url, openerTabId }); |
||||
const openNewTab = (url, openerTabId, background = false, adjacent = false) => { |
||||
if (adjacent) { |
||||
return browser.tabs.query({ |
||||
active: true, currentWindow: true |
||||
}).then((tabs) => { |
||||
return browser.tabs.create({ |
||||
url, |
||||
openerTabId, |
||||
active: !background, |
||||
index: tabs[0].index + 1 |
||||
}); |
||||
}); |
||||
} |
||||
return browser.tabs.create({ url, active: !background }); |
||||
}; |
||||
|
||||
const openToTab = (url, tab) => { |
||||
return browser.tabs.update(tab.id, { url: url }); |
||||
}; |
||||
|
||||
export { openToTab, openNewTab }; |
||||
export { openNewTab, openToTab }; |
||||
|
Reference in new issue