You can also use the nsIStyleSheetService
:
loadCSS: function() {
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"]
.getService(Components.interfaces.nsIStyleSheetService);
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var uri = ios.newURI("chrome://addon/skin/style.css", null, null);
if(!sss.sheetRegistered(uri, sss.USER_SHEET))
sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
}
If you use USER_SHEET
, the website's own CSS rules have higher priority than yours. Using AGENT_SHEET
, your CSS should have higher priority.
In any way I needed to enforce some rules by using hte !important
keyword.