-
Notifications
You must be signed in to change notification settings - Fork 16
/
conex-actions-common.js
35 lines (30 loc) · 1.24 KB
/
conex-actions-common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const renderTabContainers = async function(parent, topContainer) {
const tabs = browser.tabs.query({audible: true});
const identities = browser.contextualIdentities.query({});
const newContainerMode = (await browser.browserAction.getBadgeText({})) == 'new';
browser.browserAction.setBadgeText({text: ''});
const identitiesWithAudibleContainers = (await tabs).map(x => x.cookieStoreId);
const contexts = [{cookieStoreId: 'firefox-private', color: 'private', name: 'private browsing tabs'},
{cookieStoreId: 'firefox-default', color: 'default', name: 'default'}]
.concat((await identities).sort((a,b) => a.name.toLowerCase() > b.name.toLowerCase()))
if(topContainer) {
const topElement = contexts.splice(contexts.findIndex(e => e.cookieStoreId == topContainer), 1);
contexts.unshift(null);
contexts.unshift(topElement[0]);
}
for(const context of contexts) {
if(context == null) {
parent.appendChild($e('br'));
} else {
parent.appendChild(
createTabContainerHeaderElement(
context.cookieStoreId,
context.color,
context.name,
1,
'',
identitiesWithAudibleContainers.includes(context.cookieStoreId)));
}
}
return newContainerMode;
}