Merge pull request #4 from USLTD/patch-1

This commit is contained in:
xenos
2025-11-24 05:06:23 +01:00
committed by GitHub
+7 -7
View File
@@ -329,10 +329,10 @@ const patchApp = async () => {
asar.extractAll(asarPath, extractPath); asar.extractAll(asarPath, extractPath);
console.log(chalk.greenBright`[+] Extracted to ${extractPath}`); console.log(chalk.greenBright`[+] Extracted to ${extractPath}`);
// Step 6: Check if preload.js exists // Step 6: Check if preload.cjs exists
const preloadPath = path.join(extractPath, "build", "preload.js"); const preloadPath = path.join(extractPath, "build", "preload.cjs");
if (!fs.existsSync(preloadPath)) { if (!fs.existsSync(preloadPath)) {
console.error(chalk.redBright`[-] preload.js not found at ${preloadPath}`); console.error(chalk.redBright`[-] preload.cjs not found at ${preloadPath}`);
rm(extractPath); rm(extractPath);
process.exit(1); process.exit(1);
} }
@@ -347,7 +347,7 @@ const patchApp = async () => {
} }
console.log(chalk.greenBright`[+] Inject code fetched successfully`); console.log(chalk.greenBright`[+] Inject code fetched successfully`);
// Step 8: Read preload.js and check if already patched // Step 8: Read preload.cjs and check if already patched
let preloadContent = fs.readFileSync(preloadPath, "utf-8"); let preloadContent = fs.readFileSync(preloadPath, "utf-8");
const isPatched = preloadContent.includes("injectPageContextHooks"); const isPatched = preloadContent.includes("injectPageContextHooks");
@@ -379,7 +379,7 @@ const patchApp = async () => {
} }
if (insertIndex === -1) { if (insertIndex === -1) {
console.error(chalk.redBright`[-] Could not find insertion point (electron_1) in preload.js`); console.error(chalk.redBright`[-] Could not find insertion point (electron_1) in preload.cjs`);
rm(extractPath); rm(extractPath);
process.exit(1); process.exit(1);
} }
@@ -388,9 +388,9 @@ const patchApp = async () => {
preloadContent = lines.join("\n"); preloadContent = lines.join("\n");
} }
// Step 9: Write patched preload.js // Step 9: Write patched preload.cjs
fs.writeFileSync(preloadPath, preloadContent, "utf-8"); fs.writeFileSync(preloadPath, preloadContent, "utf-8");
console.log(chalk.greenBright`[+] preload.js patched successfully`); console.log(chalk.greenBright`[+] preload.cjs patched successfully`);
// Step 10: Repackage app.asar // Step 10: Repackage app.asar
console.log(chalk.yellowBright`[+] Repackaging app.asar...`); console.log(chalk.yellowBright`[+] Repackaging app.asar...`);