diff --git a/scripts/patcher/common.js b/scripts/patcher/common.js index 840c842..3217d5c 100644 --- a/scripts/patcher/common.js +++ b/scripts/patcher/common.js @@ -95,13 +95,12 @@ async function getMenuItem(installations) { info, })); - if (menuItems.length === 0) { - console.log("No Discord installations found."); - process.exit(1); - } - const result = await menu( - [...menuItems, { title: "Exit without patching", exit: true }], + [ + ...menuItems, + { title: "Specify custom path", info: "custom" }, + { title: "Exit without patching", exit: true } + ], { header: "Select a Discord installation to patch:", border: true, @@ -116,6 +115,33 @@ async function getMenuItem(installations) { process.exit(0); } + if (result.info === "custom") { + const customPath = await question("Please enter the path: "); + if (!customPath || !fs.existsSync(customPath)) { + console.log("No such Path or not specifed."); + process.exit(); + } + + const resourceDir = path.join(customPath, "resources"); + if (!fs.existsSync(path.join(resourceDir, "app.asar"))) { + console.log("Unsupported Install. resources/app.asar not found"); + process.exit(); + } + + const appDir = path.join(resourceDir, "app"); + result.info = { + branch: "unknown", + patched: fs.existsSync(appDir), + location: customPath, + versions: [{ + path: appDir, + name: null + }], + arch: process.platform === "linux" ? "linux" : "win32", + isFlatpak: false, + }; + } + if (result.info.patched) { const answer = await question( "This installation has already been modified. Overwrite? [Y/n]: "