mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-11 15:43:02 -04:00
feat: Proper CSS api & css bundle (#269)
Co-authored-by: Vap0r1ze <superdash993@gmail.com>
This commit is contained in:
parent
2172cae779
commit
2e5d27b6b6
31 changed files with 438 additions and 126 deletions
|
@ -44,6 +44,34 @@ contextBridge.exposeInMainWorld("VencordNative", VencordNative);
|
|||
if (location.protocol !== "data:") {
|
||||
// Discord
|
||||
webFrame.executeJavaScript(readFileSync(join(__dirname, "renderer.js"), "utf-8"));
|
||||
const rendererCss = join(__dirname, "renderer.css");
|
||||
|
||||
function insertCss(css: string) {
|
||||
const style = document.createElement("style");
|
||||
style.id = "vencord-css-core";
|
||||
style.textContent = css;
|
||||
|
||||
if (document.readyState === "complete") {
|
||||
document.documentElement.appendChild(style);
|
||||
} else {
|
||||
document.addEventListener("DOMContentLoaded", () => document.documentElement.appendChild(style), {
|
||||
once: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const css = readFileSync(rendererCss, "utf-8");
|
||||
insertCss(css);
|
||||
} catch (err) {
|
||||
if ((err as NodeJS.ErrnoException)?.code !== "ENOENT")
|
||||
throw err;
|
||||
|
||||
// hack: the pre update updater does not download this file, so manually download it
|
||||
// TODO: remove this in a future version
|
||||
ipcRenderer.invoke(IpcEvents.DOWNLOAD_VENCORD_CSS)
|
||||
.then(insertCss);
|
||||
}
|
||||
require(process.env.DISCORD_PRELOAD!);
|
||||
} else {
|
||||
// Monaco Popout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue