Skip to content

Commit

Permalink
(feat): support firefox containers
Browse files Browse the repository at this point in the history
CONTAINER_URL
CONTAINER_TITLE
  • Loading branch information
natask committed Sep 4, 2021
1 parent 3259df4 commit 457a1c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion common/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,19 @@ export async function getContextState({ baseTab, selectedTabs, callbackOption }
selectedTabs
).length > 1;

const tabs = isAll ?
let tabs = isAll ?
(await browser.tabs.query({
windowId: baseTab.windowId,
hidden: false,
}).catch(_error => [])) :
(isTree && await collectTabsFromTree(treeItem, { onlyDescendants })) || selectedTabs;
tabs = await Promise.all(tabs.map(async (tab) => {
tab.container = await browser.contextualIdentities.get(tab.cookieStoreId).then(function(container){
return container.name;
}, function(_){
return null;
});
return tab;}));
return { isAll, isTree, onlyDescendants, hasMultipleTabs, tabs };
}

Expand Down Expand Up @@ -328,6 +335,8 @@ function fillPlaceHoldersInternal(
.replace(/%(?:RLINK|RLINK_HTML(?:IFIED)?|SEL|SEL_HTML(?:IFIED)?)%/gi, '')
.replace(/%URL%/gi, tab.url)
.replace(/%(?:TITLE|TEXT)%/gi, tab.title)
.replace(/%CONTAINER_TITLE%/gi, tab.container ? tab.container + ': ' : '')
.replace(/%CONTAINER_URL%/gi, tab.container ? 'ext+container:name=' + tab.container + '&url=' : '')
.replace(/%URL_HTML(?:IFIED)?%/gi, sanitizeHtmlText(tab.url))
.replace(/%TITLE_HTML(?:IFIED)?%/gi, sanitizeHtmlText(tab.title))
.replace(/%AUTHOR%/gi, author || '')
Expand Down
2 changes: 2 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"author": "YUKI \"Piro\" Hiroshi",
"description": "__MSG_extensionDescription__",
"permissions": [
"cookies",
"contextualIdentities",
"activeTab",
"clipboardWrite",
"menus",
Expand Down

0 comments on commit 457a1c2

Please sign in to comment.