master
Drake 1 year ago
parent 01466b092f
commit 2cc56516b6

@ -5,7 +5,7 @@ import esbuild from "esbuild";
await esbuild.build({
entryPoints: ["src/index.js"],
bundle: true,
minify: true,
//minify: true,
format: "iife",
target: "es2021",
outfile: "dist/Aliucord.js"

@ -1,5 +1,6 @@
{
"dependencies": {
"demonpatcher": "^0.1.0",
"esbuild": "^0.14.37",
"http-server": "^14.1.0"
},

@ -1,10 +1,12 @@
lockfileVersion: 5.3
lockfileVersion: 5.4
specifiers:
demonpatcher: ^0.1.0
esbuild: ^0.14.37
http-server: ^14.1.0
dependencies:
demonpatcher: 0.1.0
esbuild: 0.14.37
http-server: 14.1.0
@ -63,10 +65,19 @@ packages:
/debug/3.2.7:
resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
dependencies:
ms: 2.1.3
dev: false
/demonpatcher/0.1.0:
resolution: {integrity: sha512-TSBeIo+CtGxdy8ACmdgaiM1txbaHbmkOiWXF/y7V5IR1DYkXY+0M4Npma381r0fGGlQ2nQa5zY7hXp5qw1wOGQ==}
dev: false
/esbuild-android-64/0.14.37:
resolution: {integrity: sha512-Jb61ihbS3iSj3+PhURe7sEuBg4h16CeT4CiT3W4Aop6rr5p/N6IvNXNWFX0gzUaRWtGoAFfCXFBEIn6zWUU3hQ==}
engines: {node: '>=12'}
@ -361,6 +372,7 @@ packages:
url-join: 4.0.1
transitivePeerDependencies:
- debug
- supports-color
dev: false
/iconv-lite/0.6.3:
@ -411,6 +423,8 @@ packages:
async: 2.6.4
debug: 3.2.7
mkdirp: 0.5.6
transitivePeerDependencies:
- supports-color
dev: false
/qs/6.10.3:

@ -1,41 +1,100 @@
//alert("hi :)")
//MODULE FINDER
const fullMods = [];
const getAllModules = () => {
const fullMods = []
if (fullMods.length > 0) return fullMods;
let idx = 0;
for (const k in modules) {
try {
fullMods.push([__r(Number(k)),Number(k)])
let id = Number(k)
let module = modules[id];
if (module?.publicModule?.exports["proxygone"] === null) {
alert(JSON.stringify(module))
Object.defineProperty(modules, id, {
value: modules[id],
enumerable: false,
configurable: true,
writable: true
})
continue
}
fullMods.push([__r(Number(k)), Number(k)]);
//__r(Number(k))
//fullMods.push(modules[k]?.publicModule)
} catch (e) {}
idx++;
}
return fullMods
}
return fullMods;
};
const findModules = (filter) => {
const mod = []
const mod = [];
getAllModules().forEach((item, idx) => {
if (item[0] !== undefined && item[0] !== {}) {
/*if (item[0]) {
if (filter(item[0])) {
mod.push(modules[item[1]].publicModule)
mod.push(modules[item[1]].publicModule);
}
}*/
// NOTE: ^ is how AliuRN used to do it when i first wrote this afaik; unsure if they do it now because AliuRN code is about as comprehensible as me wanting to fuck the Ink Demon (ie not at all)
let module = modules[item[1]].publicModule.exports
if (module) {
if (module.default && module.__esModule && filter(module.default)) {
mod.push(module.default)
//alert(JSON.stringify(module));
}
//if (module.exports && filter(module.exports)) {
// mod.push(module.exports)
// alert(JSON.stringify(module));
//}
if (filter(module)) {
mod.push(module)
//alert(JSON.stringify(module));
}
}
})
for (const k in mod[0]) {
//alert(`${k}\n${mod[0][k]}`)
}
return mod
}
});
mod.filter((e) => _.isEmpty(e))
return mod;
};
function findByProps(prop) {
return findModules((mod) => {return !!mod[prop]})[0]
return findModules((mod) => {
return !!mod[prop];
})[0];
}
function findAllByProps(prop) {
return findModules(mod => !!mod[prop])
return findModules((mod) => !!mod[prop]);
}
function findByName(prop) {
return findModules((mod) => m?.name === prop)[0];
}
function findAllByName(prop) {
return findModules((mod) => m?.name === prop);
}
function findByDisplayName(prop) {
return findModules((mod) => m?.displayName === prop)[0];
}
function findAllByDisplayName(prop) {
return findModules((mod) => m?.displayName === prop);
}
export default {
findModules,
findByProps,
findAllByProps
}
findAllByProps,
findByName,
findAllByName,
findByDisplayName,
findAllByDisplayName
};

@ -0,0 +1,84 @@
function wackyPatch(parentObj, name, patches) {
if (typeof parentObj === "string") {
//assume parentObj and name are switched around (for backcompat/convienence)
const tmp = parentObj;
parentObj = name;
name = tmp;
}
const injId = Symbol();
const before = patches["before"];
const instead = patches["instead"];
const after = patches["after"];
const handler = {
apply: (target, thisArg, [ctx, args]) => {
console.log(thisArg);
if (before !== undefined) before.apply(ctx, [args]);
const res =
patches["instead"] !== undefined
? instead === null || instead === void 0
? void 0
: instead.apply(ctx, [args, target.bind(ctx), ctx])
: target.apply(ctx, args);
if (after === undefined) return res;
return after.apply(ctx, [args, res]);
}
};
const prox = new Proxy(parentObj[name], handler);
const orig = parentObj[name];
parentObj[name] = function () {
return prox(this, arguments);
};
const unpatch = () => {
parentObj[name] = orig;
};
parentObj[injId] = {
name: name,
orig: orig,
unpatch: unpatch
};
return unpatch;
}
function before(parentObj, name, func) {
return wackyPatch(parentObj, name, { before: func });
}
function instead(parentObj, name, func) {
return wackyPatch(parentObj, name, { instead: func });
}
function after(parentObj, name, func) {
return wackyPatch(parentObj, name, { after: func });
}
//idea shamelessly ripped from vencord, but done slightly differently (ie allowing for targetting specific webpack functions)
function regexPatch(match, replace, obj, prop) {
const oldFunc = obj[prop];
const injId = Symbol();
const handler = {
apply: (target, thisArg, [ctx, args]) => {
let oldfunc = target;
let str = oldFunc.toString();
str = str.replaceAll(match, replace);
console.log("(" + str + ")");
let newfunc = eval.apply(ctx, ["(" + str + ")"]);
console.log(ctx);
return newfunc.apply(ctx, args);
}
};
const prox = new Proxy(obj[prop], handler);
const orig = obj[prop];
obj[prop] = prox;
const unpatch = () => {
obj[prop] = orig;
};
obj[injId] = {
name: prop,
orig: orig,
unpatch: unpatch
};
return unpatch;
}
export { instead, before, after, regexPatch };
export default {
instead,
before,
after,
regexPatch
};

@ -1,16 +1,31 @@
import metro from "./api/metro"
import metro from "./api/metro";
import patcher from "./api/patcher"
window.demon = {
modules: {
common: {
Logger: metro.findByProps("setLogFn").exports.default
logger: metro.findByProps("setLogFn"),
moment: metro.findByProps("isMoment")
},
metro
}
}
},
patcher
};
try {
log = new demon.modules.common.Logger()
log.name = "Demoncord"
log.log("Hi from the bundle :)")
} catch (e) {alert(e.stack)}
//alert(JSON.stringify(demon.modules.common.moment))
//fixme; this should either be removed (and aliu's method of blacklisting moment be used) or actually respect the user's locale
demon.modules.common.moment.locale("en")
//log = new demon.modules.common.Logger();
//JSON.stringify(demon.modules.common.logger)
//log.name = "Demoncord";
// patcher.after("log", log, function() {alert(JSON.stringify(arguments))})
//log.log("Hi from the bundle :)");
//alert(JSON.stringify(metro.findAllByProps("sendMessage")))
patcher.after("sendMessage", metro.findByProps("sendMessage").exports, (args)=>alert(args))
} catch (e) {
alert(e.stack);
}

Loading…
Cancel
Save