aboutsummaryrefslogtreecommitdiff
path: root/src/background/tabs.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/tabs.js')
-rw-r--r--src/background/tabs.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/background/tabs.js b/src/background/tabs.js
index b34f7c2..d50d8e5 100644
--- a/src/background/tabs.js
+++ b/src/background/tabs.js
@@ -1,3 +1,13 @@
+let prevSelTab = 1;
+let currSelTab = 1;
+
+browser.tabs.onActivated.addListener((activeInfo) => {
+ return browser.tabs.query({ currentWindow: true }).then(() => {
+ prevSelTab = currSelTab;
+ currSelTab = activeInfo.tabId;
+ });
+});
+
const closeTab = (id) => {
return browser.tabs.remove(id);
};
@@ -93,6 +103,10 @@ const selectLastTab = () => {
});
};
+const selectPrevSelTab = () => {
+ return browser.tabs.update(prevSelTab, { active: true });
+};
+
const reload = (current, cache) => {
return browser.tabs.reload(
current.id,
@@ -117,6 +131,6 @@ const duplicate = (id) => {
export {
closeTab, reopenTab, selectAt, selectByKeyword, getCompletions,
- selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload,
- updateTabPinned, toggleTabPinned, duplicate
+ selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, selectPrevSelTab,
+ reload, updateTabPinned, toggleTabPinned, duplicate
};