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
28 changes: 25 additions & 3 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 @@ -169,7 +170,6 @@ export class DiscordBotClient extends EventEmitter {
const disabledFeatures = new Set(app.commandLine.getSwitchValue("disable-features").split(","));
// Allow Localhost SSL
app.commandLine.appendSwitch("allow-insecure-localhost", "true");
app.commandLine.appendSwitch("ignore-certificate-errors");
app.commandLine.appendSwitch("host-rules", `MAP ${Constants.CustomDiscordDomain} 127.0.0.1:${this.port}`);
// Vesktop
// Disable renderer backgrounding to prevent the app from unloading when in the background
Expand Down Expand Up @@ -242,6 +242,20 @@ export class DiscordBotClient extends EventEmitter {
]);
app.whenReady().then(async () => {
this.logger.info("Creating session...");
app.on("certificate-error", (event, webContents, url, error, certificate, callback) => {
try {
const { hostname } = new URL(url);
if (
hostname === Constants.CustomDiscordDomain ||
hostname === "localhost" ||
hostname === "127.0.0.1"
) {
Comment on lines +248 to +252
event.preventDefault();
return callback(true);
}
} catch {}
callback(false);
});
this.customSession = session.fromPartition("persist:elysia_dbc");
// Enable DoH (Cloudflare)
app.configureHostResolver({
Expand Down Expand Up @@ -333,8 +347,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.`);
}
}
async createWindow () {
this.setupTray();
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