Bug 1653751 - Inject a rule into junk log to style it with dark system theme. r=mkmelin DONTBUILD
This commit is contained in:
Родитель
858c5e698a
Коммит
50cf02f907
|
@ -12,12 +12,16 @@ function onLoad() {
|
|||
gLogView = document.getElementById("logView");
|
||||
gLogView.docShell.allowJavascript = false; // for security, disable JS
|
||||
|
||||
gLogView.addEventListener("load", () => {
|
||||
addStyling();
|
||||
});
|
||||
|
||||
gLogFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
gLogFile.append("junklog.html");
|
||||
|
||||
if (gLogFile.exists()) {
|
||||
// convert the file to a URL so we can load it.
|
||||
gLogView.setAttribute("src", Services.io.newFileURI(gLogFile).spec);
|
||||
} else {
|
||||
addStyling(); // set style for initial about:blank
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,3 +31,14 @@ function clearLog() {
|
|||
gLogView.setAttribute("src", "about:blank"); // we don't have a log file to show
|
||||
}
|
||||
}
|
||||
|
||||
function addStyling() {
|
||||
let style = gLogView.contentDocument.createElement("style");
|
||||
gLogView.contentDocument.head.appendChild(style);
|
||||
style.sheet.insertRule(
|
||||
`@media (prefers-color-scheme: dark) {
|
||||
:root { scrollbar-color: rgba(249, 249, 250, .4) rgba(20, 20, 25, .3);}
|
||||
body { color: #f9f9fa;}
|
||||
}`
|
||||
);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче