Merge pull request #137 from alx741/tabs

Most recently used tab selector
This commit is contained in:
Shin'ya Ueoka 2018-01-14 00:29:08 +00:00 committed by GitHub
commit 423d17aeb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 2 deletions

View file

@ -27,6 +27,8 @@ const exec = (operation, tab) => {
return tabs.selectFirstTab();
case operations.TAB_LAST:
return tabs.selectLastTab();
case operations.TAB_PREV_SEL:
return tabs.selectPrevSelTab();
case operations.TAB_RELOAD:
return tabs.reload(tab, operation.cache);
case operations.TAB_PIN:

View file

@ -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
};