Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/AppCore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import contextMenu from "electron-context-menu";
import { scope } from "electron-log";
import { autoUpdater } from "electron-updater";
import EventEmitter from "events";
import fs from "fs";
import path from "path";

import server from "./APIServer";
Expand Down Expand Up @@ -333,8 +334,16 @@ export class DiscordBotClient extends EventEmitter {
},
);
// Load Vencord-Web Extension
const extension = await this.session.extensions.loadExtension(Constants.VencordExtensionPath);
this.logger.info(`Loaded Vencord Extension v${extension.version} from ${Constants.VencordExtensionPath}`);
if (fs.existsSync(Constants.VencordExtensionPath)) {
try {
const extension = await this.session.extensions.loadExtension(Constants.VencordExtensionPath);
this.logger.info(`Loaded Vencord Extension v${extension.version} from ${Constants.VencordExtensionPath}`);
} catch (err) {
this.logger.error("Failed to load Vencord extension:", err);
}
} else {
this.logger.warn(`Vencord extension not found at ${Constants.VencordExtensionPath}, running without extension.`);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, this app is entirely unusable without Vencord.

}
Comment on lines 336 to +346
}
async createWindow () {
this.setupTray();
Expand Down Expand Up @@ -461,6 +470,22 @@ export class DiscordBotClient extends EventEmitter {
});
// WebContents Event
this.win.webContents
.on("will-navigate", (event, navigationUrl) => {
try {
const parsed = new URL(navigationUrl);
const isAllowedHost =
parsed.hostname === Constants.CustomDiscordDomain ||
parsed.hostname === "localhost" ||
parsed.hostname === "127.0.0.1";
const isAllowedProtocol = parsed.protocol === "https:" || (parsed.protocol === "http:" && parsed.hostname !== Constants.CustomDiscordDomain);
if (!isAllowedHost || !isAllowedProtocol) {
event.preventDefault();
shell.openExternal(navigationUrl);
}
Comment on lines +480 to +484
} catch {
event.preventDefault();
}
})
Comment on lines 471 to +488
.on("did-create-window", (window, details) => {
window.show();
window.on("closed", () => {
Expand Down
15 changes: 6 additions & 9 deletions src/overrides.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
/* Copyright Elysia © 2025. All rights reserved */

import "express";

import type { IncomingHttpHeaders } from "http";

import type { DiscordBotClient } from "./AppCore";

declare module "express-serve-static-core" {
interface Request {
originalHeaders: IncomingHttpHeaders;
rawBody?: string;
}
}

declare global {
namespace Express {
interface Request {
originalHeaders: IncomingHttpHeaders;
rawBody?: string;
}
}
interface BigInt {
toJSON(): string;
}
Expand Down