|
1 | 1 | // ==UserScript==
|
2 | 2 | // @name Misc. Mods
|
3 |
| -// @version 2.0.2 |
| 3 | +// @version 2.0.3 |
4 | 4 | // @author aminomancer
|
5 | 5 | // @homepage https://github.com/aminomancer/uc.css.js
|
6 | 6 | // @description Various tiny mods not worth making separate scripts for. Read the comments inside the script for details.
|
|
123 | 123 | // yourself if you use my CSS theme. If you don't, then make sure you add
|
124 | 124 | // `:root{--in-content-bg-dark: #000}` to your userChrome.css, or it will fall back to white.
|
125 | 125 | "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, |
126 | 150 | };
|
127 | 151 | class UCMiscMods {
|
128 | 152 | constructor() {
|
|
144 | 168 | if (config["Don't exit DOM fullscreen when opening permissions popup"])
|
145 | 169 | this.permsPopupInFullscreen();
|
146 | 170 | if (config["Customize tab drag preview background color"]) this.tabDragPreview();
|
| 171 | + if (config["Show container icons on multiselected tabs"]) |
| 172 | + this.containerIconsOnMultiselectedTabs(); |
147 | 173 | this.randomTinyStuff();
|
148 | 174 | }
|
149 | 175 | stopDownloadsPanelFocus() {
|
|
325 | 351 | )
|
326 | 352 | );
|
327 | 353 | }
|
| 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 | + } |
328 | 387 | randomTinyStuff() {
|
329 | 388 | // give the tracking protection popup's info button a tooltip
|
330 | 389 | let etpPanel = document
|
|
0 commit comments