From 91e6ca6d8c39e8e7e09272f5e32ce0b2020fd8e7 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Fri, 31 Jan 2025 17:33:26 +0800 Subject: [PATCH] fix prototype injection again --- postinit.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/postinit.js b/postinit.js index 1b5af72..53b8868 100644 --- a/postinit.js +++ b/postinit.js @@ -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; + } } } });