mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
!feat: tabGroups API for Firefox 139
This commit is contained in:
@@ -68,13 +68,10 @@ async function createGroup(group: GroupItem, windowId: number, discard?: boolean
|
|||||||
createProperties: { windowId }
|
createProperties: { windowId }
|
||||||
});
|
});
|
||||||
|
|
||||||
// Grouping support came in 138, tabGroups is expected to be in 139
|
await chrome.tabGroups.update(groupId, {
|
||||||
// TODO: Remove this check once the API is available
|
title: group.title,
|
||||||
if (!import.meta.env.FIREFOX)
|
color: group.color
|
||||||
await chrome.tabGroups.update(groupId, {
|
});
|
||||||
title: group.title,
|
|
||||||
color: group.color
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function manageWindow(handle: (windowId: number) => Promise<void>, windowProps?: Windows.CreateCreateDataType): Promise<void>
|
async function manageWindow(handle: (windowId: number) => Promise<void>, windowProps?: Windows.CreateCreateDataType): Promise<void>
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "tabs-aside",
|
"name": "tabs-aside",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "3.0.0-rc4",
|
"version": "3.0.0-rc5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "wxt",
|
"dev": "wxt",
|
||||||
|
|||||||
@@ -88,17 +88,9 @@ async function createCollectionFromTabs(tabs: Tabs.Tab[]): Promise<[CollectionIt
|
|||||||
tabs.every(i => i.groupId === tabs[0].groupId)
|
tabs.every(i => i.groupId === tabs[0].groupId)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// TODO: Remove the check when Firefox 139 is out
|
const group = await chrome.tabGroups.get(tabs[0].groupId);
|
||||||
if (!import.meta.env.FIREFOX)
|
collection.title = group.title;
|
||||||
{
|
collection.color = group.color;
|
||||||
const group = await browser.tabGroups!.get(tabs[0].groupId);
|
|
||||||
collection.title = group.title;
|
|
||||||
collection.color = group.color;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
collection.color = "blue";
|
|
||||||
}
|
|
||||||
|
|
||||||
tabs.forEach(i =>
|
tabs.forEach(i =>
|
||||||
collection.items.push({ type: "tab", url: i.url!, title: i.title })
|
collection.items.push({ type: "tab", url: i.url!, title: i.title })
|
||||||
@@ -123,27 +115,14 @@ async function createCollectionFromTabs(tabs: Tabs.Tab[]): Promise<[CollectionIt
|
|||||||
if (!activeGroup || activeGroup !== tab.groupId)
|
if (!activeGroup || activeGroup !== tab.groupId)
|
||||||
{
|
{
|
||||||
activeGroup = tab.groupId;
|
activeGroup = tab.groupId;
|
||||||
|
const group = await chrome.tabGroups.get(activeGroup);
|
||||||
|
|
||||||
// TODO: Remove the check when Firefox 139 is out
|
collection.items.push({
|
||||||
if (import.meta.env.FIREFOX)
|
type: "group",
|
||||||
{
|
color: group.color,
|
||||||
collection.items.push({
|
title: group.title,
|
||||||
type: "group",
|
items: []
|
||||||
color: "blue",
|
});
|
||||||
items: []
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const group = await browser.tabGroups!.get(activeGroup);
|
|
||||||
|
|
||||||
collection.items.push({
|
|
||||||
type: "group",
|
|
||||||
color: group.color,
|
|
||||||
title: group.title,
|
|
||||||
items: []
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(collection.items[collection.items.length - 1] as GroupItem).items.push({
|
(collection.items[collection.items.length - 1] as GroupItem).items.push({
|
||||||
|
|||||||
+5
-7
@@ -24,7 +24,8 @@ export default defineConfig({
|
|||||||
description: "__MSG_manifest_description__",
|
description: "__MSG_manifest_description__",
|
||||||
homepage_url: "https://github.com/xfox111/TabsAsideExtension/",
|
homepage_url: "https://github.com/xfox111/TabsAsideExtension/",
|
||||||
|
|
||||||
action: {
|
action:
|
||||||
|
{
|
||||||
default_title: "__MSG_manifest_name__"
|
default_title: "__MSG_manifest_name__"
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -36,7 +37,8 @@ export default defineConfig({
|
|||||||
"tabs",
|
"tabs",
|
||||||
"notifications",
|
"notifications",
|
||||||
"contextMenus",
|
"contextMenus",
|
||||||
"bookmarks"
|
"bookmarks",
|
||||||
|
"tabGroups"
|
||||||
],
|
],
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
@@ -78,17 +80,13 @@ export default defineConfig({
|
|||||||
gecko:
|
gecko:
|
||||||
{
|
{
|
||||||
id: "tabsaside@xfox111.net",
|
id: "tabsaside@xfox111.net",
|
||||||
strict_min_version: "138.0"
|
strict_min_version: "139.0"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error author key in Firefox has a different format
|
// @ts-expect-error author key in Firefox has a different format
|
||||||
manifest.author = "__MSG_manifest_author__";
|
manifest.author = "__MSG_manifest_author__";
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
manifest.permissions!.push("tabGroups");
|
|
||||||
}
|
|
||||||
|
|
||||||
return manifest;
|
return manifest;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user