Bug 1653751 - Inject a rule into junk log to style it with dark system theme. r=mkmelin DONTBUILD

This commit is contained in:
Richard Marti ext:(%2C%20Magnus%20Melin%20%3Cmkmelin%2Bmozilla%40iki.fi%3E) 2020-07-23 12:41:51 +03:00
Родитель 858c5e698a
Коммит 50cf02f907
1 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -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;}
}`
);
}