Unbrick OpenAsar installs

This commit is contained in:
Vendicated 2022-10-22 18:34:29 +02:00
parent 2eb8f3ae19
commit 0328966e0f
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3

View file

@ -29,11 +29,13 @@ console.log("[Vencord] Starting up...");
// Our injector file at app/index.js
const injectorPath = require.main!.filename;
// The original app.asar
const discordPath = join(dirname(injectorPath), "..", "app.asar");
// Full main path Discord uses
require.main!.filename = join(discordPath, "app_bootstrap/index.js");
const asarPath = join(dirname(injectorPath), "..", "app.asar");
const discordPkg = require(join(asarPath, "package.json"));
require.main!.filename = join(asarPath, discordPkg.main);
// @ts-ignore Untyped method? Dies from cringe
app.setAppPath(discordPath);
app.setAppPath(asarPath);
// Repatch after host updates on Windows
if (process.platform === "win32")
@ -121,5 +123,6 @@ if (readFileSync(injectorPath, "utf-8").includes('require("../app.asar")')) {
return loadModule.apply(this, arguments);
};
} else {
require(discordPath);
console.log(require.main!.filename);
require(require.main!.filename);
}