Skip to content

Commit

Permalink
Fix style priority (no need to use !important)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlvzk committed Jan 17, 2023
1 parent 41c8357 commit 64da8b8
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions discocss
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,33 @@ module.exports = () => {
const confDir = "$confdir";
const cssFile = "$cssFile";
let lastStyleID;
function reload() {
if (lastStyleID) electron.webFrame.removeInsertedCSS(lastStyleID);
const css = fs.readFileSync(cssFile, { encoding: "utf-8" });
lastStyleID = electron.webFrame.insertCSS(css);
electron.webFrame.executeJavaScript(\`
(() => {
let loaded = false;
function load() {
if (loaded) return;
const disco = document.createElement("style");
disco.id = "disco";
disco.innerHTML = \${JSON.stringify(css)};
document.getElementById('disco')?.remove();
document.head.appendChild(disco);
loaded = true;
}
window.addEventListener("load", () => {
load();
});
try {
load();
} catch (e) {}
})();
\`);
}
reload();
Expand Down

0 comments on commit 64da8b8

Please sign in to comment.