diff options
Diffstat (limited to 'src/background')
-rw-r--r-- | src/background/actions/tab.js | 18 | ||||
-rw-r--r-- | src/background/components/background.js | 6 |
2 files changed, 19 insertions, 5 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 }; diff --git a/src/background/components/background.js b/src/background/components/background.js index fdec8ec..fae3fbb 100644 --- a/src/background/components/background.js +++ b/src/background/components/background.js @@ -33,8 +33,10 @@ export default class BackgroundComponent { sender); case messages.OPEN_URL: if (message.newTab) { - return this.store.dispatch( - tabActions.openNewTab(message.url, sender.tab.id), sender); + let action = tabActions.openNewTab( + message.url, sender.tab.id, message.background, + settings.value.properties.adjacenttab); + return this.store.dispatch(action, sender); } return this.store.dispatch( tabActions.openToTab(message.url, sender.tab), sender); |