|
|
@ -1,5 +1,13 @@ |
|
|
|
let prevSelTab = 0; |
|
|
|
let prevSelTab = 1; |
|
|
|
let currSelTab = 2; |
|
|
|
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) => { |
|
|
|
const closeTab = (id) => { |
|
|
|
return browser.tabs.remove(id); |
|
|
|
return browser.tabs.remove(id); |
|
|
@ -71,6 +79,7 @@ const selectPrevTab = (current, count) => { |
|
|
|
} |
|
|
|
} |
|
|
|
let select = (current - count + tabs.length) % tabs.length; |
|
|
|
let select = (current - count + tabs.length) % tabs.length; |
|
|
|
let id = tabs[select].id; |
|
|
|
let id = tabs[select].id; |
|
|
|
|
|
|
|
currSelTab = id; |
|
|
|
return browser.tabs.update(id, { active: true }); |
|
|
|
return browser.tabs.update(id, { active: true }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -86,6 +95,7 @@ const selectNextTab = (current, count) => { |
|
|
|
} |
|
|
|
} |
|
|
|
let select = (current + count) % tabs.length; |
|
|
|
let select = (current + count) % tabs.length; |
|
|
|
let id = tabs[select].id; |
|
|
|
let id = tabs[select].id; |
|
|
|
|
|
|
|
currSelTab = id; |
|
|
|
return browser.tabs.update(id, { active: true }); |
|
|
|
return browser.tabs.update(id, { active: true }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -97,6 +107,7 @@ const selectFirstTab = () => { |
|
|
|
|
|
|
|
|
|
|
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => { |
|
|
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => { |
|
|
|
let id = tabs[0].id; |
|
|
|
let id = tabs[0].id; |
|
|
|
|
|
|
|
currSelTab = id; |
|
|
|
return browser.tabs.update(id, { active: true }); |
|
|
|
return browser.tabs.update(id, { active: true }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -108,6 +119,7 @@ const selectLastTab = () => { |
|
|
|
|
|
|
|
|
|
|
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => { |
|
|
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => { |
|
|
|
let id = tabs[tabs.length - 1].id; |
|
|
|
let id = tabs[tabs.length - 1].id; |
|
|
|
|
|
|
|
currSelTab = id; |
|
|
|
return browser.tabs.update(id, { active: true }); |
|
|
|
return browser.tabs.update(id, { active: true }); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|