如何使用 userChrome.css 设置 Firefox 的 URL 栏的背景颜色?

问题描述

我正在尝试使用 userChrome.css 更改 Firefox URL 栏的背景颜色。在 these steps 之后,我将以下代码添加到我的 userChrome.css

@-moz-document url(chrome://browser/content/browser.xul),url(chrome://browser/content/browser.xhtml) {
    #urlbar {
        background-color: red !important;
    }
}

它根本不起作用。我怎样才能做到这一点?

解决方法

首先,您需要在 toolkit.legacyUserProfileCustomizations.stylesheets 中将 true 首选项设置为 about:config,如here 所述。

现在,要使用的正确 CSS 标识符是 #urlbar-background

@-moz-document url(chrome://browser/content/browser.xul),url(chrome://browser/content/browser.xhtml) {
    #urlbar-background{
        background-color: red !important;
    }
}

(我从 this file 那里了解到这一点;整个存储库非常有启发性。)