r1-apk-patcher/index.js

31 lines
918 B
JavaScript
Raw Normal View History

2024-05-29 11:23:53 -05:00
const fs = require("fs");
2024-05-31 04:27:01 -05:00
const {functions} = require("./functions");
2024-07-01 14:48:48 -05:00
const {decomp, modifyFunc, replaceLib, build, replaceStringInManifest} = require("./utils");
2024-05-31 04:27:01 -05:00
const settings = require("./settings.json");
2024-05-29 11:23:53 -05:00
2024-05-31 04:27:01 -05:00
const decompName = settings.apkFileName;
const base = `${decompName}_decompile_xml`;
2024-05-29 11:23:53 -05:00
2024-07-01 14:48:48 -05:00
const appVersion = "20240615.10-dirty";
2024-05-31 04:27:01 -05:00
decomp();
2024-07-01 14:48:48 -05:00
2024-05-31 04:27:01 -05:00
functions.functions.forEach(func => {
modifyFunc(`./${base}/`+func.location, func.code)
})
2024-05-29 11:23:53 -05:00
2024-07-01 14:48:48 -05:00
replaceStringInManifest("android:versionName", `"${appVersion}"`)
replaceLib("./libbase.so", "libbase.so");
2024-05-29 11:23:53 -05:00
2024-05-31 04:27:01 -05:00
if(fs.existsSync(`./${decompName}_out.apk`)) fs.rmSync(`./${decompName}_out.apk`);
if(fs.existsSync(`./${decompName}_Patched.apk`)) fs.rmSync(`./${decompName}_Patched.apk`);
2024-05-29 11:23:53 -05:00
build();
fs.renameSync(
`${base}_out-aligned-debugSigned.apk`,
`${decompName}_Patched.apk`
);
2024-06-24 11:26:34 -05:00
fs.rmSync(`./${base}`, { recursive: true, force: true });
2024-05-31 04:27:01 -05:00
fs.rmSync(`${base}_out.apk`);