diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-05-01 14:17:29 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-01 14:17:29 +0900 |
commit | 89d6afecfd257ff4fc62748f771abf37ef3a2852 (patch) | |
tree | f0ebc8a1a7a9f29dc4775dea62ae89166837c4c1 /src/background/actions/tab.js | |
parent | fb8a0f36aa4d070df936cc7598ef8dd988ee1b15 (diff) | |
parent | daefddf8b86f2844b9ad2220cb2983129a366484 (diff) |
Merge pull request #171 from idlewan/background-adjacent-tabs
Open adjacent tabs and background tabs
Diffstat (limited to 'src/background/actions/tab.js')
-rw-r--r-- | src/background/actions/tab.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/background/actions/tab.js b/src/background/actions/tab.js index 40da55d..3c642fd 100644 --- a/src/background/actions/tab.js +++ b/src/background/actions/tab.js @@ -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 }; |