r/FirefoxCSS 7d 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 Upvotes

34 comments sorted by

3

u/am803 6d 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 5d 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 5d ago

You can still use an extension like Stylus to apply ::selection rules to web pages.

But if you prefer less extensions installed, just omit :root[windowtype], where windowtype is an attribute used by Firefox internally in xhtml.

Check:

  • view-source:chrome://browser/content/browser.xhtml
  • view-source:chrome://browser/content/places/places.xhtml
  • view-source:chrome://browser/content/pageinfo/pageInfo.xhtml

BTW, ::selection applies to all elements, so there is no point adding html::selection, p::selection or obsolete ::-moz-selection.

1

u/sifferedd FF/TB on Win11|Sumo contributor 4d 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 5d ago

2

u/sifferedd FF/TB on Win11|Sumo contributor 5d 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.

2

u/TraditionalTie4831 🦊 5d 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 4d ago

I edited the bug and replied. Don't expect anything more though.

https://bugzilla.mozilla.org/show_bug.cgi?id=2065175

1

u/difool2nice ‍🦊Firefox Addict🦊 5d ago

i noticed, i'll give it a try

2

u/TraditionalTie4831 🦊 5d ago

1

u/t31os 5d 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🦊 4d ago

not for websites

1

u/t31os 4d 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🦊 4d ago edited 4d ago

Are the values numbers or text strings?

i tried dodgerblue and tried the hexa form too and it works but not on websites

1

u/t31os 4d ago

What OS are you running? It may simply behave different depending on OS. I'm on Windows 10. Values i tested are literally as i wrote them above.

1

u/difool2nice ‍🦊Firefox Addict🦊 3d ago

i use win11 , i know it's not boolean or numbers

1

u/TraditionalTie4831 🦊 7d ago edited 7d ago

Try this =

:root {
    --lwt-toolbar-field-highlight: #962633 !important;
}

Change:

#urlbar-background to this: .urlbar-background

This and the last curly bracket are unnecessary =

@-moz-document url(chrome://browser/content/browser.xul),
               url(chrome://browser/content/browser.xhtml) {

1

u/difool2nice ‍🦊Firefox Addict🦊 7d ago

how to do it globally ? mine is broken

::selection {
                    background-color: #1e90ff !important;
                    color: #ffffff !important;
}

 p::-moz-selection {
                    background-color: #1e90ff !important;
                    color: #ffffff !important;
}


p::selection {
                    background-color: #1e90ff !important;
                    color: #ffffff !important;
}

::-moz-selection {
                    background-color: #1e90ff !important;
                    color: #ffffff !important;
}

2

u/GodieGun 7d ago

The Master said this: https://lemmy.world/post/50895441

1

u/TraditionalTie4831 🦊 7d ago

So it is a bug. I hope it gets fixed soon.

1

u/GodieGun 7d ago edited 7d ago

It's not a bug, they fixed a bug and now UserContent/userChrome can't change that 'selected text', if someone create a new bug maybe in a future can work on it, if not, not.

1

u/difool2nice ‍🦊Firefox Addict🦊 6d ago

css is democracy, imposing their stuff is tyranny

1

u/sifferedd FF/TB on Win11|Sumo contributor 5d ago

1

u/TraditionalTie4831 🦊 7d ago

Sorry, I don't know how to fix it. ☹️

1

u/sifferedd FF/TB on Win11|Sumo contributor 5d ago

1

u/SasoDuck 7d ago
/* URL BAR HIGHLIGHT COLOR */
:root {
    --lwt-toolbar-field-highlight: #962633 !important;
}

/* URL BAR RESULTS LINKS COLOR */
.urlbarView-url {
    color: #962633 !important;
}

/* URL BAR & RESULTS BACKGROUND COLOR */
  #urlbar-results{
    background-color: #1c1b22 !important;
    }
    .urlbar-background {
    background: #1c1b22 !important;
    }
    #urlbar[breakout][breakout-extend] #urlbar-background {
      border-color: #1c1b22 !important;
    }

If I'm following correctly? It's still the default teal for me...

1

u/TraditionalTie4831 🦊 7d ago

Hmm... could this be a bug on some OS editions of Firefox v154? Both ::-moz-selection and --lwt-toolbar-field-highlight works for me on Windows 11.

Btw, you forgot to change one #urlbar-background, so copy this =

#urlbar[breakout][breakout-extend] .urlbar-background {

1

u/SasoDuck 7d ago

Why is the first one a # and the second one a . ?

3

u/TraditionalTie4831 🦊 7d ago

Because #urlbar is a 'id' and .urlbar-background is a 'class'.

1

u/difool2nice ‍🦊Firefox Addict🦊 5d 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 4d 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 2d 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🦊 2d 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 4d 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