experimental regex patcher

slightly ripped from vencord, but implemented differently due to
environmental differences
master
Drake 2 years ago
parent 2e68d5f124
commit a4af53251c

@ -64,10 +64,25 @@ function after(parentObj: any, name: string, func: AfterFunc) {
return wackyPatch(parentObj, name, { after: func });
}
export { instead, before, after };
//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) {
let str: string = obj[prop].toString()
str = str.replaceAll(match, replace)
let newfunc = (new Function("return " + str))()
obj[prop] = newfunc
}
export {
instead,
before,
after,
regexPatch
};
export default {
instead,
before,
after
after,
regexPatch
};

Loading…
Cancel
Save