refactor
This commit is contained in:
parent
0a6148c73f
commit
e8f1d1db1e
60 changed files with 2417 additions and 612 deletions
16
js/patch_helpers.js
Normal file
16
js/patch_helpers.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
|
||||
(function (global) {
|
||||
const applied = new Set();
|
||||
function patchPrototype(key, owner, patchFn) {
|
||||
if (!key || !owner?.prototype || typeof patchFn !== "function") return false;
|
||||
const fullKey = `${owner.name || "Owner"}:${key}`;
|
||||
if (applied.has(fullKey) || owner.prototype[`__${key}Patched`]) return false;
|
||||
patchFn(owner.prototype);
|
||||
applied.add(fullKey);
|
||||
owner.prototype[`__${key}Patched`] = true;
|
||||
return true;
|
||||
}
|
||||
function patchWorld(key, patchFn) { return patchPrototype(key, global.World, patchFn); }
|
||||
global.TarinaiPatcher = { patchPrototype, patchWorld, applied };
|
||||
})(typeof window !== "undefined" ? window : globalThis);
|
||||
Loading…
Add table
Add a link
Reference in a new issue