Move all platforms to discord_desktop_core

This commit is contained in:
Zack Rauen 2022-10-26 22:24:08 -04:00
parent 7442dde2fa
commit c9c0d6e545
3 changed files with 1 additions and 57 deletions

View File

@ -1,6 +1,4 @@
import path from "path";
import {app} from "electron";
import Module from "module";
import ipc from "./modules/ipc";
import BrowserWindow from "./modules/browserwindow";
@ -18,8 +16,7 @@ if (!process.argv.includes("--vanilla")) {
// Remove CSP immediately on linux since they install to discord_desktop_core still
if (process.platform == "win32" || process.platform == "darwin") app.once("ready", CSP.remove);
else CSP.remove();
CSP.remove();
}
// Enable DevTools on Stable.
@ -35,15 +32,6 @@ Object.defineProperty(global, "appSettings", {
},
});
// Use Discord's info to run the app
if (process.platform == "win32" || process.platform == "darwin") {
const basePath = path.join(app.getAppPath(), "..", "app.asar");
const pkg = __non_webpack_require__(path.join(basePath, "package.json"));
app.setAppPath(basePath);
app.name = pkg.name;
Module._load(path.join(basePath, pkg.main), null, true);
}
// Needs to run this after Discord but before ready()
if (!process.argv.includes("--vanilla")) {
const BetterDiscord = require("./modules/betterdiscord").default;

View File

@ -46,16 +46,6 @@ export default class BetterDiscord {
if (!fs.existsSync(path.join(dataPath, "themes"))) fs.mkdirSync(path.join(dataPath, "themes"));
}
static async ensureWebpackModules(browserWindow) {
await browserWindow.webContents.executeJavaScript(`new Promise(resolve => {
const check = function() {
if (window.webpackJsonp && window.webpackJsonp.flat().flat().length >= 7000) return resolve();
setTimeout(check, 100);
};
check();
});`);
}
static async injectRenderer(browserWindow) {
const location = path.join(__dirname, "renderer.js");
if (!fs.existsSync(location)) return; // TODO: cut a fatal log

View File

@ -1,37 +1,3 @@
import fs from "fs";
import path from "path";
import Module from "module";
// const Module = require("module");
Module.globalPaths.push(path.resolve(process.env.DISCORD_APP_PATH, "..", "app.asar", "node_modules"));
// module.paths.push(path.resolve(process.env.DISCORD_APP_PATH, "..", "app.asar", "node_modules"));
Module._load = (load => (req, parent, isMain) => {
if (req.includes("./") || req.includes("..")) return load(req, parent, isMain);
const found = Module.globalPaths.find(m => fs.existsSync(path.resolve(m, req)));
return found ? load(path.resolve(found, req), parent, isMain) : load(req, parent, isMain);
})(Module._load);
// const originalLoad = Module.prototype.load;
// Module.prototype.load = function() {
// const returnValue = Reflect.apply(originalLoad, this, arguments);
// console.log(this, arguments, returnValue);
// return returnValue;
// };
// const nodeModulePaths = Module._nodeModulePaths;
// console.log(nodeModulePaths);
// Module._nodeModulePaths = (from) => {
// return nodeModulePaths(from).concat([path.resolve(process.env.DISCORD_APP_PATH, "..", "app.asar", "node_modules")]);
// };
// console.log(Module._nodeModulePaths, Module._nodeModulePaths("request"));
// console.dir(Module);
// console.log(Object.keys(Module));
// console.log(require("request"));
export * as filesystem from "./filesystem";
export {default as https} from "./https";
export * as electron from "./electron";