aboutsummaryrefslogtreecommitdiff
path: root/src/preload.ts
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-10-22 04:41:33 +0200
committerVendicated <vendicated@riseup.net>2022-10-22 04:42:54 +0200
commit44f6f71c3efd2e4e0f9dbd97ab4680ec76536052 (patch)
treecd2ad847833ff428e009ca55b50eabd57031443d /src/preload.ts
parent23d4cae1230bd60da2f0497ecac9d4a32a326f5b (diff)
downloadVencord-44f6f71c3efd2e4e0f9dbd97ab4680ec76536052.tar.gz
Vencord-44f6f71c3efd2e4e0f9dbd97ab4680ec76536052.tar.bz2
Vencord-44f6f71c3efd2e4e0f9dbd97ab4680ec76536052.zip
Monaco for Discord Desktop
Diffstat (limited to 'src/preload.ts')
-rw-r--r--src/preload.ts15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/preload.ts b/src/preload.ts
index 7244a1d..5de4298 100644
--- a/src/preload.ts
+++ b/src/preload.ts
@@ -21,6 +21,7 @@ import { readFileSync } from "fs";
import { join } from "path";
import VencordNative from "./VencordNative";
import IpcEvents from "./utils/IpcEvents";
+import { debounce } from "./utils/debounce";
if (electron.desktopCapturer === void 0) {
// Fix for desktopCapturer being main only in Electron 17+
@@ -39,6 +40,14 @@ if (electron.desktopCapturer === void 0) {
contextBridge.exposeInMainWorld("VencordNative", VencordNative);
-webFrame.executeJavaScript(readFileSync(join(__dirname, "renderer.js"), "utf-8"));
-
-require(process.env.DISCORD_PRELOAD!);
+if (location.protocol !== "data:") {
+ // Discord
+ webFrame.executeJavaScript(readFileSync(join(__dirname, "renderer.js"), "utf-8"));
+ require(process.env.DISCORD_PRELOAD!);
+} else {
+ // Monaco Popout
+ contextBridge.exposeInMainWorld("setCss", debounce(s => VencordNative.ipc.invoke(IpcEvents.SET_QUICK_CSS, s)));
+ contextBridge.exposeInMainWorld("getCurrentCss", () => VencordNative.ipc.invoke(IpcEvents.GET_QUICK_CSS));
+ // shrug
+ contextBridge.exposeInMainWorld("getTheme", () => "vs-dark");
+}