@@ -223,24 +223,27 @@ document.querySelector("#version").textContent = _("Version",
223223 var currentPolicy = await UI . getPolicy ( cookieStoreId ) ;
224224
225225 function updateContainersEnabled ( ) {
226- const containersEnabled = Boolean ( contextStore . enabled && browser . contextualIdentities ) ;
227- document . querySelector ( "#containers-opt" ) . style . display = browser . contextualIdentities ? "" : "none" ;
228- document . querySelector ( "#opt-containers" ) . disabled = ! browser . contextualIdentities ;
226+ const supported = browser . contextualIdentities && ! contextStore . disabledByHost ;
227+ const containersEnabled = supported && contextStore . enabled ;
228+ document . querySelector ( "#containers-opt" ) . style . display = supported ? "" : "none" ;
229+ document . querySelector ( "#opt-containers" ) . disabled = ! supported ;
229230 document . querySelector ( "#opt-containers" ) . checked = contextStore . enabled ;
230- document . querySelector ( "#container-options" ) . style . display = containersEnabled ? "" : "none" ;
231+ document . querySelector ( "#container-options" ) . style . display = supported ? "" : "none" ;
231232 }
232233 updateContainersEnabled ( ) ;
233234
234- function constrainContainerCopy ( ) {
235+ function syncContainerSelectors ( ) {
235236 containerCopy . disabled = cookieStoreId == "default" ;
236237 for ( const opt of containerCopy . options ) {
237- opt . disabled = opt . value == cookieStoreId ;
238+ if ( opt . disabled = ( opt . value == cookieStoreId ) ) {
239+ document . querySelector ( "#container-options" ) . style . setProperty ( "--container-color" , opt . style . color ) ;
240+ }
238241 }
239242 }
240243
241244 async function changeContainer ( ) {
242245 cookieStoreId = containerSelect . value ;
243- constrainContainerCopy ( ) ;
246+ syncContainerSelectors ( ) ;
244247 currentPolicy = await UI . getPolicy ( cookieStoreId ) ;
245248 debug ( "container change" , cookieStoreId , currentPolicy ) ;
246249 sitesUI . clear ( )
@@ -275,9 +278,7 @@ document.querySelector("#version").textContent = _("Version",
275278 let newContainers = [ { cookieStoreId : "default" , name : "Default" } , ] ;
276279 let identities = browser . contextualIdentities && await browser . contextualIdentities . query ( { } ) ;
277280 if ( identities ) {
278- identities . forEach ( ( { cookieStoreId, name} ) => {
279- newContainers . push ( { cookieStoreId, name} ) ;
280- } )
281+ newContainers . push ( ...identities ) ;
281282 }
282283 if ( JSON . stringify ( newContainers ) == JSON . stringify ( containers ) ) return ;
283284 containers = newContainers ;
@@ -286,6 +287,7 @@ document.querySelector("#version").textContent = _("Version",
286287 const o = options . appendChild ( document . createElement ( "option" ) ) ;
287288 o . value = container . cookieStoreId ;
288289 o . text = container . name ;
290+ o . style . color = container . colorCode || "" ;
289291 }
290292 while ( containerSelect . firstChild ) {
291293 containerSelect . removeChild ( containerSelect . firstChild ) ;
@@ -298,7 +300,7 @@ document.querySelector("#version").textContent = _("Version",
298300 containerCopy . appendChild ( document . createElement ( "option" ) ) . value = "blank" ;
299301 containerCopy . appendChild ( options ) ;
300302
301- constrainContainerCopy ( ) ;
303+ syncContainerSelectors ( ) ;
302304 }
303305 containerSelect . onfocus = updateContainerOptions ;
304306 containerCopy . onfocus = updateContainerOptions ;
0 commit comments