Improvements for VencordDesktop (#847)
This commit is contained in:
parent
bfa20f2634
commit
08822dd190
13 changed files with 85 additions and 147 deletions
|
|
@ -26,27 +26,23 @@ import VencordNative from "./VencordNative";
|
|||
|
||||
contextBridge.exposeInMainWorld("VencordNative", VencordNative);
|
||||
|
||||
// Discord
|
||||
if (location.protocol !== "data:") {
|
||||
// Discord
|
||||
webFrame.executeJavaScript(readFileSync(join(__dirname, "renderer.js"), "utf-8"));
|
||||
// #region cssInsert
|
||||
const rendererCss = join(__dirname, "renderer.css");
|
||||
|
||||
function insertCss(css: string) {
|
||||
const style = document.createElement("style");
|
||||
style.id = "vencord-css-core";
|
||||
style.textContent = css;
|
||||
const style = document.createElement("style");
|
||||
style.id = "vencord-css-core";
|
||||
style.textContent = readFileSync(rendererCss, "utf-8");
|
||||
|
||||
if (document.readyState === "complete") {
|
||||
document.documentElement.appendChild(style);
|
||||
} else {
|
||||
document.addEventListener("DOMContentLoaded", () => document.documentElement.appendChild(style), {
|
||||
once: true
|
||||
});
|
||||
}
|
||||
if (document.readyState === "complete") {
|
||||
document.documentElement.appendChild(style);
|
||||
} else {
|
||||
document.addEventListener("DOMContentLoaded", () => document.documentElement.appendChild(style), {
|
||||
once: true
|
||||
});
|
||||
}
|
||||
|
||||
const css = readFileSync(rendererCss, "utf-8");
|
||||
insertCss(css);
|
||||
if (IS_DEV) {
|
||||
// persistent means keep process running if watcher is the only thing still running
|
||||
// which we obviously don't want
|
||||
|
|
@ -54,11 +50,14 @@ if (location.protocol !== "data:") {
|
|||
document.getElementById("vencord-css-core")!.textContent = readFileSync(rendererCss, "utf-8");
|
||||
});
|
||||
}
|
||||
// #endregion
|
||||
|
||||
if (process.env.DISCORD_PRELOAD)
|
||||
if (process.env.DISCORD_PRELOAD) {
|
||||
webFrame.executeJavaScript(readFileSync(join(__dirname, "renderer.js"), "utf-8"));
|
||||
require(process.env.DISCORD_PRELOAD);
|
||||
} else {
|
||||
// Monaco Popout
|
||||
}
|
||||
} // Monaco popout
|
||||
else {
|
||||
contextBridge.exposeInMainWorld("setCss", debounce(s => VencordNative.ipc.invoke(IpcEvents.SET_QUICK_CSS, s)));
|
||||
contextBridge.exposeInMainWorld("getCurrentCss", () => VencordNative.ipc.invoke(IpcEvents.GET_QUICK_CSS));
|
||||
// shrug
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue