fix prototype injection again

This commit is contained in:
ZXMushroom63 2025-01-31 17:33:26 +08:00
parent e38fd7c111
commit 91e6ca6d8c

View File

@ -396,9 +396,14 @@ globalThis.modapi_postinit = "(" + (() => {
//Prototype Injection, allows for far easier access to methods
if (typeof item === "function" && ModAPI.hooks._rippedMethodTypeMap[method] === "instance") {
item.prototype["$" + method.replace(compiledName + "_", "")] = function (...args) {
var prototypeInjectedMethod = function prototypeInjectedMethod(...args) {
return ModAPI.hooks.methods[method].apply(this, [this, ...args]);
}
if ((item.prototype["$" + method.replace(compiledName + "_", "")]?.name ?? "prototypeInjectedMethod") === "prototypeInjectedMethod") {
item.prototype["$" + method.replace(compiledName + "_", "")] = prototypeInjectedMethod;
} else {
item.prototype["$" + method.replace(compiledName + "_", "")] ||= prototypeInjectedMethod;
}
}
}
});