aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/background/tabs.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/background/tabs.js b/src/background/tabs.js
index 07083c5..a5a2adc 100644
--- a/src/background/tabs.js
+++ b/src/background/tabs.js
@@ -1,5 +1,13 @@
-let prevSelTab = 0;
-let currSelTab = 2;
+let prevSelTab = 1;
+let currSelTab = 1;
+
+browser.tabs.onActivated.addListener(tabChangeHandler);
+
+function tabChangeHandler(activeInfo) {
+ prevSelTab = currSelTab;
+ currSelTab = activeInfo.tabId;
+ console.log("prev tab: " + prevSelTab + " - curr tab: " + currSelTab);
+}
const closeTab = (id) => {
return browser.tabs.remove(id);
@@ -71,6 +79,7 @@ const selectPrevTab = (current, count) => {
}
let select = (current - count + tabs.length) % tabs.length;
let id = tabs[select].id;
+ currSelTab = id;
return browser.tabs.update(id, { active: true });
});
};
@@ -86,6 +95,7 @@ const selectNextTab = (current, count) => {
}
let select = (current + count) % tabs.length;
let id = tabs[select].id;
+ currSelTab = id;
return browser.tabs.update(id, { active: true });
});
};
@@ -97,6 +107,7 @@ const selectFirstTab = () => {
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
let id = tabs[0].id;
+ currSelTab = id;
return browser.tabs.update(id, { active: true });
});
};
@@ -108,6 +119,7 @@ const selectLastTab = () => {
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
let id = tabs[tabs.length - 1].id;
+ currSelTab = id;
return browser.tabs.update(id, { active: true });
});
};