|
|
|
@ -27,7 +27,7 @@ function wackyPatch(
|
|
|
|
|
thisArg: any,
|
|
|
|
|
[ctx, args]: [ctx: any, args: []]
|
|
|
|
|
) => {
|
|
|
|
|
console.log(thisArg)
|
|
|
|
|
console.log(thisArg);
|
|
|
|
|
if (before !== undefined) before.apply(ctx, [args]);
|
|
|
|
|
const res =
|
|
|
|
|
patches["instead"] !== undefined
|
|
|
|
@ -66,8 +66,13 @@ function after(parentObj: any, name: string, func: AfterFunc) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//idea shamelessly ripped from vencord, but done slightly differently (ie allowing for targetting specific webpack functions)
|
|
|
|
|
function regexPatch(match: RegExp | string, replace: string, obj: any, prop: string) {
|
|
|
|
|
const oldFunc = obj[prop]
|
|
|
|
|
function regexPatch(
|
|
|
|
|
match: RegExp | string,
|
|
|
|
|
replace: string,
|
|
|
|
|
obj: any,
|
|
|
|
|
prop: string
|
|
|
|
|
) {
|
|
|
|
|
const oldFunc = obj[prop];
|
|
|
|
|
const injId = Symbol();
|
|
|
|
|
const handler = {
|
|
|
|
|
apply: (
|
|
|
|
@ -75,18 +80,18 @@ function regexPatch(match: RegExp | string, replace: string, obj: any, prop: str
|
|
|
|
|
thisArg: any,
|
|
|
|
|
[ctx, args]: [ctx: any, args: []]
|
|
|
|
|
) => {
|
|
|
|
|
let oldfunc = target
|
|
|
|
|
let str: string = oldFunc.toString()
|
|
|
|
|
str = str.replaceAll(match, replace)
|
|
|
|
|
console.log("(" + str + ")")
|
|
|
|
|
let newfunc = eval.apply(ctx, ["(" + str + ")"])
|
|
|
|
|
console.log(ctx)
|
|
|
|
|
return newfunc.apply(ctx, args)
|
|
|
|
|
let oldfunc = target;
|
|
|
|
|
let str: string = 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
|
|
|
|
|
obj[prop] = prox;
|
|
|
|
|
const unpatch = () => {
|
|
|
|
|
obj[prop] = orig;
|
|
|
|
|
};
|
|
|
|
@ -98,13 +103,7 @@ function regexPatch(match: RegExp | string, replace: string, obj: any, prop: str
|
|
|
|
|
return unpatch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export {
|
|
|
|
|
instead,
|
|
|
|
|
before,
|
|
|
|
|
after,
|
|
|
|
|
regexPatch
|
|
|
|
|
};
|
|
|
|
|
export { instead, before, after, regexPatch };
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
instead,
|
|
|
|
|