r/FirefoxCSS • u/Real-Wrongdoer8590 • 4h ago
Help help hoFirefox hotreloading colors when i update my theme files (Help)
I am currently trying to theme librewolf i have customized my userchrome.css and userContent.css to load colors from my current theme i but whenever i change my theme i have to restart firefox I found this script online and customized it a little by using chatgpt it Hotreloads userChrome.css it updates the browser colors (but i still have to paste it in browser's consol CTRL SHIFT J) I am wondering if there is some kind of bashscript that could send a signal to the browser to hotreload so currently I am having two problems
- the script does not load userContent.css
- how do i execute the script
this here is the script
(() => {
const Cc = Components.classes;
const Ci = Components.interfaces;
const sss = Cc["@mozilla.org/content/style-sheet-service;1"]
.getService(Ci.nsIStyleSheetService);
const io = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
const ds = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties);
// Locate current-theme.css in the profile's chrome folder.
const file = ds.get("UChrm", Ci.nsIFile);
file.append("current-theme.css");
if (!file.exists()) {
console.error("File not found:", file.path);
return;
}
const uri = io.newFileURI(file);
// Unregister the existing stylesheet.
if (sss.sheetRegistered(uri, sss.USER_SHEET)) {
sss.unregisterSheet(uri, sss.USER_SHEET);
console.log("Unregistered:", file.path);
}
// Register the stylesheet again.
try {
sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
console.log("Registered:", file.path);
} catch (e) {
console.error("Failed to register stylesheet:", e);
}
})();
can i get some suggestions on how i should approach this or some sources
I know there is something called fx-config which allows you to add JS to the browser but it comes with security concerns
librewolf version: LibreWolf 158.0-1
OS Arch Linux



