Add temporary fix for mac stable

- fixes #889
- fixes #918
- fixes #896
This commit is contained in:
Zack Rauen 2021-07-27 17:19:45 -04:00
parent 3e863cb286
commit 84fe58294c
2 changed files with 22 additions and 10 deletions

View File

@ -77,6 +77,12 @@ export default class BetterDiscord {
static setup(browserWindow) {
// Setup some useful vars to avoid blocking IPC calls
try {
process.env.DISCORD_RELEASE_CHANNEL = __non_webpack_require__(buildInfoFile).releaseChannel;
}
catch (e) {
process.env.DISCORD_RELEASE_CHANNEL = "stable";
}
process.env.DISCORD_PRELOAD = browserWindow.__originalPreload;
process.env.DISCORD_APP_PATH = appPath;
process.env.DISCORD_USER_DATA = electron.app.getPath("userData");

View File

@ -23,18 +23,24 @@ Object.defineProperty(window, "webpackJsonp", {
electron.webFrame.top.context.global = electron.webFrame.top.context;
electron.webFrame.top.context.require = require;
electron.webFrame.top.context.Buffer = Buffer;
electron.webFrame.top.context.process = new class PatchedProcess extends NodeEvents {
get __ORIGINAL_PROCESS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED__() {return process;}
constructor() {
super();
if (process.platform === "darwin" && process.env.DISCORD_RELEASE_CHANNEL !== "canary") {
electron.webFrame.top.context.process = process;
}
else {
electron.webFrame.top.context.process = new class PatchedProcess extends NodeEvents {
get __ORIGINAL_PROCESS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED__() {return process;}
Object.assign(this,
cloneObject(process, {}, Object.keys(NodeEvents.prototype)),
cloneObject(process, {})
);
}
};
constructor() {
super();
Object.assign(this,
cloneObject(process, {}, Object.keys(NodeEvents.prototype)),
cloneObject(process, {})
);
}
};
}
// Load Discord's original preload
const preload = process.env.DISCORD_PRELOAD;