如何通过代码覆盖皮肤的设置?
我有一个 Firefox 扩展,可以更改浏览器的选项卡颜色,如下所示:
tabBrowser.tabContainer.childNodes[i].style.backgroundColor = "#8f8";
这段代码在我的开发配置文件中运行良好,但在工作配置文件中我安装了一个主题 (Noia 2.0 eXtreme),它为选项卡设置了自己的外观,所以我的代码无法更改选项卡的颜色。是否可以通过代码覆盖主题的设置?
我就是不明白。我找到了皮肤的CSS文件,看起来很简单。
tab {
-moz-appearance: none;
padding: 1px 5px 2px 7px;
border-top: 1px solid;
border-right: 2px solid;
border-left: 1px solid;
-moz-border-top-colors: #FFFFFF;
-moz-border-right-colors: #808080 #404040;
-moz-border-left-colors: #FFFFFF;
-moz-border-radius-topleft: 8px;
-moz-border-radius-topright: 8px;
background-color: #CDCED3;
color: #606060;
min-height: 20px !important
}
tab[selected="true"] {
margin-top: 0;
padding: 1px 7px 4px 9px;
font-weight: bold;
background-image : url("chrome://browser/skin/icons/Bookmark-background.png") !important;
border-bottom: 1px solid;
-moz-border-bottom-colors: #FFFFFF;
color: #000000;
}
tab:hover {
color: #000000 !important;
}
环境
tabBrowser.tabContainer.childNodes[i].style.setProperty("background-image", "none", "important");
I have a Firefox extension that changes a browser's tab color like this:
tabBrowser.tabContainer.childNodes[i].style.backgroundColor = "#8f8";
This code works fine in my development profile, but in the working profile I have a theme installed (Noia 2.0 eXtreme), that sets its own appearance for the tabs, so my code can not change the tab's color. Is it possible to override the theme's settings through the code?
I just do not get it. I have found the skin's CSS file, it seems pretty simple.
tab {
-moz-appearance: none;
padding: 1px 5px 2px 7px;
border-top: 1px solid;
border-right: 2px solid;
border-left: 1px solid;
-moz-border-top-colors: #FFFFFF;
-moz-border-right-colors: #808080 #404040;
-moz-border-left-colors: #FFFFFF;
-moz-border-radius-topleft: 8px;
-moz-border-radius-topright: 8px;
background-color: #CDCED3;
color: #606060;
min-height: 20px !important
}
tab[selected="true"] {
margin-top: 0;
padding: 1px 7px 4px 9px;
font-weight: bold;
background-image : url("chrome://browser/skin/icons/Bookmark-background.png") !important;
border-bottom: 1px solid;
-moz-border-bottom-colors: #FFFFFF;
color: #000000;
}
tab:hover {
color: #000000 !important;
}
Setting
tabBrowser.tabContainer.childNodes[i].style.setProperty("background-image", "none", "important");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 https://developer.mozilla.org/en/DOM/CSSStyleDeclaration 你可以使用:
according to https://developer.mozilla.org/en/DOM/CSSStyleDeclaration you could use: