mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
b51dd6083f
* chore(deps): wxt 0.20.0 bump #134 * chore: 3.2.1 manifest bump
31 lines
754 B
TypeScript
31 lines
754 B
TypeScript
import { settings } from "./settings";
|
|
|
|
export async function getTabsToSaveAsync(): Promise<[Browser.tabs.Tab[], number]>
|
|
{
|
|
let tabs: Browser.tabs.Tab[] = await browser.tabs.query({
|
|
currentWindow: true,
|
|
highlighted: true
|
|
});
|
|
|
|
if (tabs.length < 2)
|
|
{
|
|
const ignorePinned: boolean = await settings.ignorePinned.getValue();
|
|
tabs = await browser.tabs.query({
|
|
currentWindow: true,
|
|
pinned: ignorePinned ? false : undefined
|
|
});
|
|
}
|
|
|
|
const tabsCount: number = tabs.length;
|
|
const extension_prefix: string = browser.runtime.getURL("/");
|
|
|
|
tabs = tabs.filter(i =>
|
|
i.url
|
|
&& new URL(i.url).protocol !== "about:"
|
|
&& new URL(i.url).hostname !== "newtab"
|
|
&& !i.url!.startsWith(extension_prefix)
|
|
);
|
|
|
|
return [tabs, tabsCount - tabs.length];
|
|
}
|