context menu changes not recognized in userChrome.css
Frequently when I update Firefox something stops working the way I want it to. So after the last update I disabled updates. That was a while ago (version 89) and my browser was getting pretty stale. So I backed everything up, reenabled updates, and now I have version 104.
And, of course, something is broken now. The context menus when I right click are not functioning as before. The userChrome.css is still there in the chrome folder in my profile and has the same contents. The option toolkit.legacyUserProfileCustomizations.stylesheets is set to true. But it doesn't work anymore. I added a line to change the color of the tab toolbar and that worked. So userChrome.css is being read and acted upon. But the other command (I whittled it down to just one additional command for testing) is ignored.
Here is what my userChrome.css looks like right now:
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
- context-openlinkintab { display:none!important; }
- TabsToolbar{ background-color: #CCCCCC !important }
But the "Open Link in New Tab" still appears in the context menu when I right click a link. It didn't do this before the upgrade to 104. Did something break in between version 89 and 104 or is it some other oddity?
Any ideas?
Chosen solution
Some menus may be working differently on Mac. I remember that there is a pref to enable native context menus what would likely disable style rules in userChrome.css when set to true.
- about:config => widget.macos.native-context-menus
All Replies (15)
penderjohnd said
Frequently when I update Firefox something stops working the way I want it to. So after the last update I disabled updates. That was a while ago (version 89) and my browser was getting pretty stale. So I backed everything up, reenabled updates, and now I have version 104. And, of course, something is broken now. The context menus when I right click are not functioning as before. The userChrome.css is still there in the chrome folder in my profile and has the same contents. The option toolkit.legacyUserProfileCustomizations.stylesheets is set to true. But it doesn't work anymore. I added a line to change the color of the tab toolbar and that worked. So userChrome.css is being read and acted upon. But the other command (I whittled it down to just one additional command for testing) is ignored. Here is what my userChrome.css looks like right now: @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");But the "Open Link in New Tab" still appears in the context menu when I right click a link. It didn't do this before the upgrade to 104. Did something break in between version 89 and 104 or is it some other oddity? Any ideas?
- context-openlinkintab { display:none!important; }
- TabsToolbar{ background-color: #CCCCCC !important }
For some reason the text of what is in userChrome.css was reformatted. It should look like this:
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); #context-openlinkintab { display:none!important; } #TabsToolbar{ background-color: #CCCCCC !important }
The #context-openlinkintab should still work, search for context-openlink to get the various IDs.
Not sure about the CSS rules for the background-color of the tabs. This works for me as a test.
#context-openlinkintab { display:none!important; } #tabbrowser-tabs, #new-tab-button, #alltabs-button { background-color: #CCCC00 !important }
It is not that difficult to create userChrome.css if you have never used it.
The first step is to open the "Help -> Troubleshooting Information" page and find the button to access the profile folder with the random name (xxxxxxxx.default-release).
You can find the button to go to the profile folder under the "Application Basics" section as "Profile Folder -> Open Folder". If you click this button then you open the profile folder in the Windows File Explorer. You need to create a folder with the name chrome in the profile folder with the random name (name is all lowercase). In the chrome folder you need to create a plain text file with the name userChrome.css (name is case sensitive). In this userChrome.css text file you paste the text posted. On Mac you can use the TextEdit utility to create the userChrome.css file as a plain text file.
In Windows saving the file is usually the only time things get more complicated because Windows can silently add a .txt file extension and you end up with a file named userChrome.css.txt. To avoid this you need to make sure to select "All files" in the dialog to save the file in the text editor using "Save File as".
You need to close (Quit/Exit) and restart Firefox when you create or modify the userChrome.css file.
More info about userContent.css and userChrome.css in case you are not familiar: *https://www.userchrome.org/what-is-userchrome-css.html
- https://www.userchrome.org/how-create-userchrome-css.html
- https://www.userchrome.org/firefox-changes-userchrome-css.html
In Firefox 69 and later you need to set this pref to true on the about:config page to enable userChrome.css and userContent.css in the chrome folder.
- about:config => toolkit.legacyUserProfileCustomizations.stylesheets = true
- https://support.mozilla.org/en-US/kb/about-config-editor-firefox
While I appreciate the prompt reply it appears from the boiler plate response that you didn't actually read my post.
- I have used userChrome.css in the past; it was working just prior to my recent version upgrade. - I know where the file should be located. - I have verified that toolkit.legacyUserProfileCustomizations.stylesheets is set to true. - In fact, userChrome.css does currently work to change the tab color.
But it does not work to hide one of the right-click context menu items. Why not?
userChrome.css scripts are not provided by Mozilla and is not officially supported.
Firefox is a work in progress and, to allow for continuous innovation, Mozilla cannot guarantee future updates won’t impact your customizations. For this reason, Mozilla does not officially support style rules customization.
Please read Firefox Advanced Customization and Configuration Options to learn more.
I understand that Mozilla offers no guarantees. That is very clear. Their "continuous innovation" is the reason why I didn't update my browser for over a year.
I'm not looking for a guarantee, just an answer to this question. Is it true that hiding right-click menu items via userChrome.css no longer works? Or is it something peculiar to my installation? If it's the former then I will be forced to accept it (or change browsers). But if it's the latter then it's worth investigating the reason why as in that case I should be able to fix it.
So does the feature work anymore or is it now broken for everybody?
Modified
Do you have other lines in your userChrome.css that might be causing problems (errors) ? Does it work if you only place these two lines in userChrome.css or move these line to the top or bottom ?
I simplified userChrome.css just three lines:
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); #context-openlinkintab { display:none!important; } #TabsToolbar{ background-color: #CCCCCC !important }
I have tried moving things around, adding spaces, putting the {} brackets on their own lines, and also checked to see if there were any invisible characters in the file. I also tried disabling the two add-ons I use and also restarting in safe mode.
My rules hiding context menu items are still working. You could try commenting out the namespace line. Remove the blank space in the first link below.
https://www.userchrome. org/adding-style-recipes-userchrome-css.html#namespaces https://developer.mozilla.org/en-US/docs/Web/CSS/@namespace
Removing the namespace line had no effect. The tab bar color is still changed and the context menu item is still not hidden.
So now I have just this:
#context-openlinkintab { display:none!important; } #TabsToolbar{ background-color: #CCCCCC !important }
Does this also fail to work with hiding other context menu entries listed on this page ?
You can use the Browser Toolbox to check whether and what rules are applied to a specific element. note that you need to enable this toolbox via the Web Developer Settings page (press F1 with the developer tools opened).
I tried adding some of the other menu entries to userChrome.css:
#context-back{ display:none!important; } #context-forward{ display:none!important; } #context-reload{ display:none!important; } #context-take-screenshot{ display:none!important; } #context-searchselect{ display:none!important; } #context-viewpartialsource-selection{ display:none!important; } #context-bookmark-page{ display:none!important; }
These additional lines had no effect on the menus.
The Browser Toolbox: I got it open but had that little-kid-wandering-around-a-giant-warehouse feeling. There is a learning curve here.
I found userChrome.css listed under styles but I'm not sure what to do with it. It's possible I'm too stupid to figure it out but I will try.
Modified
Chosen Solution
Some menus may be working differently on Mac. I remember that there is a pref to enable native context menus what would likely disable style rules in userChrome.css when set to true.
- about:config => widget.macos.native-context-menus
I would try a new profile. I find it easier to create one with Firefox closed.
For this issue you need to copy the chrome folder and the file in it to the new profile, making sure that the file name and suffix aren't changed. You would then need to change the related preference in about:config to true. I wouldn't make any other changes before testing the profile.
If it works, you can make it your default profile. You will need to reinstall extensions but you can copy other data from the old profile.
https://support.mozilla.org/en-US/kb/profile-manager-create-remove-switch-firefox-profiles https://support.mozilla.org/en-US/kb/profile-manager-create-remove-switch-firefox-profiles#w_start-the-profile-manager-when-firefox-is-closed https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data#w_what-information-is-stored-in-my-profile https://support.mozilla.org/en-US/kb/recovering-important-data-from-an-old-profile
Creating a fresh profile (with userChrome.css copied and toolkit.legacyUserProfileCustomizations.stylesheets set to true) didn't fix it. But thank you for the links to all of that useful information. It might come in handy down the road.
Setting widget.macos.native-context-menus true->false did the trick!
Thank you!
How did you know to suggest that? I had intended to mention that I'm using macOS but I never did. In any case, I really appreciate that you took the time and shared your expertise. I was considering purging Firefox from my system and doing a fresh installation but now I see that would have been a waste of time.
Thank you so much.
Now I wonder how long I can put off updating again?