Skip to content

Commit 8f3d72b

Browse files
committed
add a new feature to miscMods.uc.js:
show container tab icons on multiselected container tabs. we normally show the container by adding a colored stripe to the tab, but this color is overridden when multiselecting the tab. so when a container tab is multiselected, this new option will add a colored icon to the tab to indicate the tab's container. this feature is disabled by default, so see miscMods.uc.js
1 parent 7b353e5 commit 8f3d72b

File tree

2 files changed

+82
-14
lines changed

2 files changed

+82
-14
lines changed

JS/miscMods.uc.js

+60-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name Misc. Mods
3-
// @version 2.0.2
3+
// @version 2.0.3
44
// @author aminomancer
55
// @homepage https://github.com/aminomancer/uc.css.js
66
// @description Various tiny mods not worth making separate scripts for. Read the comments inside the script for details.
@@ -123,6 +123,30 @@
123123
// yourself if you use my CSS theme. If you don't, then make sure you add
124124
// `:root{--in-content-bg-dark: #000}` to your userChrome.css, or it will fall back to white.
125125
"Customize tab drag preview background color": true,
126+
127+
// With duskFox installed, we indicate container tabs by adding a colored
128+
// stripe at the bottom of the tab. But we also add a purple stripe at the
129+
// bottom of multiselected tabs, which overrides the container tab stripe.
130+
// So when you multiselect a container tab, you can't tell it's a container
131+
// tab until you deselect it. This mod will additionally add a CSS property
132+
// that carries the container's icon in addition to its color. That's the
133+
// same icon that shows in the urlbar on container tabs. Firefox's built-in
134+
// styles don't use this for tabs, but duskFox does. Here's the style I use
135+
// to show these icons in tabs in duskFox:
136+
// .tabbrowser-tab.identity-icon-on-multiselect[usercontextid][multiselected="true"]
137+
// .tab-content::after {
138+
// content: "";
139+
// display: -moz-box;
140+
// height: 12px;
141+
// width: 12px;
142+
// margin-inline: 3px;
143+
// background: var(--identity-icon) center/contain no-repeat;
144+
// fill: var(--identity-icon-color);
145+
// -moz-context-properties: fill;
146+
// }
147+
// This is a pretty opinionated change and it doesn't do anything without
148+
// duskFox or the above CSS, so it's disabled by default.
149+
"Show container icons on multiselected tabs": false,
126150
};
127151
class UCMiscMods {
128152
constructor() {
@@ -144,6 +168,8 @@
144168
if (config["Don't exit DOM fullscreen when opening permissions popup"])
145169
this.permsPopupInFullscreen();
146170
if (config["Customize tab drag preview background color"]) this.tabDragPreview();
171+
if (config["Show container icons on multiselected tabs"])
172+
this.containerIconsOnMultiselectedTabs();
147173
this.randomTinyStuff();
148174
}
149175
stopDownloadsPanelFocus() {
@@ -325,6 +351,39 @@
325351
)
326352
);
327353
}
354+
containerIconsOnMultiselectedTabs() {
355+
const lazy = {};
356+
XPCOMUtils.defineLazyModuleGetters(lazy, {
357+
ContextualIdentityService: "resource://gre/modules/ContextualIdentityService.jsm",
358+
});
359+
if (lazy.ContextualIdentityService.hasOwnProperty("setTabStyle")) return;
360+
lazy.ContextualIdentityService.setTabStyle = function (tab) {
361+
if (!tab.hasAttribute("usercontextid")) {
362+
return;
363+
}
364+
365+
let userContextId = tab.getAttribute("usercontextid");
366+
let identity = this.getPublicIdentityFromId(userContextId);
367+
368+
let colorPrefix = "identity-color-";
369+
let iconPrefix = "identity-icon-";
370+
/* Remove the existing container color highlight if it exists */
371+
for (let className of tab.classList) {
372+
if (className.startsWith(colorPrefix) || className.startsWith(iconPrefix)) {
373+
tab.classList.remove(className);
374+
}
375+
}
376+
if (identity) {
377+
if (identity.color) {
378+
tab.classList.add(colorPrefix + identity.color);
379+
}
380+
if (identity.icon) {
381+
tab.classList.add(iconPrefix + identity.icon);
382+
tab.classList.add(iconPrefix + "on-multiselect");
383+
}
384+
}
385+
};
386+
}
328387
randomTinyStuff() {
329388
// give the tracking protection popup's info button a tooltip
330389
let etpPanel = document

uc-tabs.css

+22-13
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,6 @@
8383
box-shadow: 0px 0px 25px 3px rgba(0, 0, 0, 0.1), 0px 0px 15px 0px hsla(0, 0%, 0%, 0.35) !important;
8484
}
8585

86-
/* colored lines on container tabs */
87-
.tabbrowser-tab[usercontextid] .tab-context-line {
88-
background: var(--identity-tab-color) !important;
89-
height: 1px !important;
90-
margin-bottom: 0 !important;
91-
}
92-
93-
/* purple line on multiselected tabs */
94-
#TabsToolbar .tabbrowser-tab[multiselected="true"] .tab-context-line {
95-
min-height: 1px !important;
96-
background-color: var(--multiselected-color) !important;
97-
}
98-
9986
.tabbrowser-tab .tab-context-line {
10087
display: -moz-box !important;
10188
-moz-box-ordinal-group: 2 !important;
@@ -105,10 +92,32 @@
10592
transition: none !important;
10693
}
10794

95+
/* colored lines on container tabs */
96+
.tabbrowser-tab[usercontextid] .tab-context-line {
97+
background-color: var(--identity-tab-color) !important;
98+
}
99+
100+
/* purple line on multiselected tabs */
101+
.tabbrowser-tab[multiselected="true"] .tab-context-line {
102+
background-color: var(--multiselected-color) !important;
103+
}
104+
108105
.tabbrowser-tab:not([usercontextid], [multiselected]) .tab-context-line {
109106
display: none !important;
110107
}
111108

109+
.tabbrowser-tab.identity-icon-on-multiselect[usercontextid][multiselected="true"]
110+
.tab-content::after {
111+
content: "";
112+
display: -moz-box;
113+
height: 12px;
114+
width: 12px;
115+
margin-inline: 3px;
116+
background: var(--identity-icon) center/contain no-repeat;
117+
fill: var(--identity-icon-color);
118+
-moz-context-properties: fill;
119+
}
120+
112121
.tab-label-container {
113122
height: revert !important;
114123
pointer-events: none !important;

0 commit comments

Comments
 (0)