aboutsummaryrefslogtreecommitdiff
path: root/src/background/actions/tab.js
blob: 3c642fd867d2d2f5a6dbbbbd43203afea7bc7e1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 { openNewTab, openToTab };