diff options
Diffstat (limited to 'src/background/tabs.js')
-rw-r--r-- | src/background/tabs.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/background/tabs.js b/src/background/tabs.js new file mode 100644 index 0000000..000bd7d --- /dev/null +++ b/src/background/tabs.js @@ -0,0 +1,23 @@ +const selectPrevTab = (current, count) => { + chrome.tabs.query({ currentWindow: true }, (tabs) => { + if (tabs.length < 2) { + return; + } + let select = (current - count) % tabs.length + let id = tabs[select].id; + chrome.tabs.update(id, { active: true }) + }); +}; + +const selectNextTab = (current, count) => { + chrome.tabs.query({ currentWindow: true }, (tabs) => { + if (tabs.length < 2) { + return; + } + let select = (current + count + tabs.length) % tabs.length + let id = tabs[select].id; + chrome.tabs.update(id, { active: true }) + }); +}; + +export { selectNextTab, selectPrevTab }; |