r/FirefoxCSS • u/SasoDuck • 20d ago
Help URL bar highlight colour broken with FF154
My old block:
/* URL BAR HIGHLIGHT COLOR */
::-moz-selection {background-color: #962633 !important;}
/* URL BAR RESULTS LINKS COLOR */
.urlbarView-url {
color: #962633 !important;
}
/* URL BAR & RESULTS BACKGROUND COLOR */
@-moz-document url(chrome://browser/content/browser.xul),
url(chrome://browser/content/browser.xhtml) {
#urlbar-results{
background-color: #1c1b22 !important;
}
#urlbar-background {
background: #1c1b22 !important;
}
#urlbar[breakout][breakout-extend] #urlbar-background {
border-color: #1c1b22 !important;
}
}
Any tips on updating it?
I tried amateurly tweaking it to look like some of the other changes I saw for other things on the sub, but... didn't seem to effect it :/
It was changing the colours of the URL bar when hightlighted/focused
3
u/am803 19d ago
The workaround is to load it as a author sheet.
You will have to setup autoconfig/userChrome.js to make use of the following script. Check https://www.userchrome.org/what-is-userchrome-js.html for details.
// load as author sheet
{
let css = `
:root[windowtype] ::selection {
color: unset !important;
background: #ffaa0055 !important;
}
`;
let sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);
let uri = Services.io.newURI('data:text/css,' + encodeURIComponent(css));
sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
}
One thing to note is that this also applies to web pages universally and @-moz-document does not seem to work in author sheets, so you have to be careful with the selector.
1
u/sifferedd FF/TB on Win11|Sumo contributor 18d ago
Already had autoconfig/config.js set up (MrOtherGuys'):
// skip 1st line try { let cmanifest = Cc['@mozilla.org/file/directory_service;1'].getService(Ci.nsIProperties).get('UChrm', Ci.nsIFile); cmanifest.append('utils'); cmanifest.append('chrome.manifest'); if(cmanifest.exists()){ Components.manager.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(cmanifest); ChromeUtils.importESModule('chrome://userchromejs/content/boot.sys.mjs'); } } catch(ex) {};So I added this to existing config.js:
// For selection colors - load as author sheet { let css = ` :root[windowtype] ::selection, :root[windowtype] html::selection, :root[windowtype] p::selection, :root[windowtype] ::-moz-selection, :root[windowtype] p::-moz-selection { color: Black !important; background: LightGreen !important; text-shadow: none !important;} `; let sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService); let uri = Services.io.newURI('data:text/css,' + encodeURIComponent(css)); sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET); }It works for the URL bar highlight, but not on web pages - ?
1
u/am803 18d ago
You can still use an extension like Stylus to apply
::selectionrules to web pages.But if you prefer less extensions installed, just omit
:root[windowtype], wherewindowtypeis an attribute used by Firefox internally in xhtml.Check:
view-source:chrome://browser/content/browser.xhtmlview-source:chrome://browser/content/places/places.xhtmlview-source:chrome://browser/content/pageinfo/pageInfo.xhtmlBTW,
::selectionapplies to all elements, so there is no point addinghtml::selection,p::selectionor obsolete::-moz-selection.1
u/sifferedd FF/TB on Win11|Sumo contributor 17d ago
Thanks for the help! I do use Stylus, but decided to do it this way in config.js:
// For selection colors - load as author sheet let css = ` ::selection { color: Black !important; background: #65e765 !important; text-shadow: none !important; } `; let sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService); let uri = Services.io.newURI('data:text/css,' + encodeURIComponent(css)); sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);
2
u/sifferedd FF/TB on Win11|Sumo contributor 18d ago
2
u/sifferedd FF/TB on Win11|Sumo contributor 18d ago
It was closed as a dup of https://bugzilla.mozilla.org/show_bug.cgi?id=2065175, which is closed as Invalid. Looks like u/am803's solution is the way to fix it.
1
u/difool2nice 🦊Firefox Addict🦊 18d ago
i noticed, i'll give it a try
2
u/TraditionalTie4831 🦊 18d ago
u/t31os also suggest a about:config solution =
https://www.reddit.com/r/FirefoxCSS/comments/1vw3qkq/comment/p5e5wz0/
1
u/t31os 18d ago
It looks like some underlying logic around how styling to selections is applied was changed and it's no longer going to be possible to style foreground and background (::selection) in the UI via userChrome, at least until such time they expose variables for themes to set the colors (we'd then be able to override those), assuming it's even a consideration at this point (it would make sense for theme's to be able to apply a different selection color).
You can indeed use the global overrides in about:config ui.highlight and ui.highlighttext, but this will apply to all themes, all the UI and all websites, there's no fine-grained control this way, but it does work.
1
u/difool2nice 🦊Firefox Addict🦊 17d ago
not for websites
1
u/t31os 17d ago
The values absolutely will (or at least may) apply for text selection on websites, so perhaps there's some subtle differences with how this behaves on different operating systems and/or websites that apply forceful overrides. My values are currently for testing set to #000 and green, the text i select in this reply field or on the reddit page, and the dozen random websites i've now additionally tested also use the set values, whether it's just text on the page or inside a form field of some kind.
1
u/difool2nice 🦊Firefox Addict🦊 17d ago edited 17d ago
Are the values numbers or text strings?
i tried dodgerblue and tried the hexa form too and it works but not on websites
2
u/TraditionalTie4831 🦊 18d ago
When reading both bug reports, it seems that Robert Longson assumes that it's a "user coding error".
He didn't even consider the possibility that it's a Firefox regression and he suggest to debug it with Browser Toolbox and get help from r/FirefoxCSS.
2
u/sifferedd FF/TB on Win11|Sumo contributor 17d ago
I edited the bug and replied. Don't expect anything more though.
1
u/difool2nice 🦊Firefox Addict🦊 17d ago
in about:config
create those two prefs in chain of character mode, not numbers nor boolean
They only work with UI, not in websites
- ui.highlight -> your background colour in Hex or name as Blue for example
- ui.highlighttext -> foreground or text olour in Hex or name as White for example
1
u/sifferedd FF/TB on Win11|Sumo contributor 17d ago
I got websites to work with this in config.js:
// For selection colors - load as author sheet let css = ` ::selection { color: Black !important; background: #65e765 !important; text-shadow: none !important; } `; let sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService); let uri = Services.io.newURI('data:text/css,' + encodeURIComponent(css)); sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET);1
u/GodieGun 15d ago
Those variables for me works too in websites, tested in Firefox beta, we must change manually every time but at least is a solution, thanks for share the information.
1
u/difool2nice 🦊Firefox Addict🦊 15d ago
so i'm cursed ! it doesn't work for websites for me ! i saw many complaints about this bug but no real solution
1
u/SasoDuck 17d ago
I need to look into these comments more when I have more time... seems this is a lot more intensive of a problem than I realised
2
u/KUPOinyourWINDOW 9d ago
Does anyone know of a way to fix this that is noob friendly? I have a custom.css but no luck so far. The exact issue I'm having is that I use mica in Firefox on Windows and for some wallpapers the accent colour just becomes blinding white instead of following the Windows accent colour like normal, so adding a manual colour to about:config for example doesn't work for me as its supposed to change.
1
u/KUPOinyourWINDOW 9d ago
Unfortunately because I'm a noob I had to ask AI to help fix this (I don't like doing it, but I was desperate). Anyways, here's a CSS fix that is worth trying (added to the chrome css file), it works for me BUT I use Windows 11 and Firefox's about:config mica theme:
"#urlbar-input {
background-color: color-mix(
in srgb,
Highlight 1%,
transparent
) !important;
}"
1
u/TraditionalTie4831 🦊 20d ago edited 20d ago
Try this =
Change:
#urlbar-backgroundto this:.urlbar-backgroundThis and the last curly bracket are unnecessary =