using bovine3dom suggestion / adding aliases

This commit is contained in:
Dranaxel 2020-05-24 12:24:01 +02:00
parent 2d8def8b81
commit 3c73886b3f
2 changed files with 5 additions and 6 deletions

View file

@ -2336,18 +2336,15 @@ export async function tabclose(...indexes: string[]) {
*/
//#background
export async function tabcloseallto(side: string) {
if !(["left", "right"].includes(side)) throw("side argument must be left or right")
const tabs = await browser.tabs.query({
pinned: false,
currentWindow: true,
})
const atab = await activeTab()
if (side == "right") {
const ids = tabs.filter(tab => tab.index > atab.index).map(tab => tab.id)
}
else if (side == "left"){
const ids = tabs.filter(tab => tab.index < atab.index).map(tab => tab.id)
}
const comp = side == "right" ? tab => tab.index > atab.index : tab => tab.index < atab.index
const ids = tabs.filter(comp).map(tab => tab.id)
return browser.tabs.remove(ids)
}

View file

@ -573,6 +573,8 @@ export class default_config {
extp: "extpreferences",
prefset: "setpref",
prefremove: "removepref",
tabclosealltoright: "tabcloseallto right"
tabclosealltoleft: "tabcloseallto left"
}
/**