mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-23 06:01:38 -09:00
v2.7.3: add config meta entry
This commit is contained in:
parent
33e829f633
commit
0f530dce2a
@ -1,4 +1,4 @@
|
||||
globalThis.ModAPIVersion = "v2.7.2";
|
||||
globalThis.ModAPIVersion = "v2.7.3";
|
||||
globalThis.doEaglerforge = true;
|
||||
document.querySelector("title").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
||||
document.querySelector("h1").innerText = `EaglerForge Injector ${ModAPIVersion}`;
|
||||
|
24
modgui.js
24
modgui.js
@ -248,15 +248,27 @@ globalThis.modapi_guikit = "(" + (() => {
|
||||
spacer.classList.add("nothing");
|
||||
var controls = document.createElement("td");
|
||||
|
||||
var button = document.createElement("button");
|
||||
button.innerText = "Delete";
|
||||
button.style.height = "3rem";
|
||||
button.addEventListener("click", async () => {
|
||||
var deleteBtn = document.createElement("button");
|
||||
deleteBtn.innerText = "Delete";
|
||||
deleteBtn.style.height = "3rem";
|
||||
deleteBtn.addEventListener("click", async () => {
|
||||
await removeMod(i);
|
||||
window.modapi_displayModGui();
|
||||
});
|
||||
button.classList.add("button");
|
||||
controls.appendChild(button);
|
||||
deleteBtn.classList.add("button");
|
||||
controls.appendChild(deleteBtn);
|
||||
|
||||
if (typeof ModAPI.meta._configMap[hash] === "function") {
|
||||
var configBtn = document.createElement("button");
|
||||
configBtn.innerText = "Delete";
|
||||
configBtn.style.height = "3rem";
|
||||
configBtn.addEventListener("click", async () => {
|
||||
ModAPI.meta._configMap[hash]();
|
||||
});
|
||||
configBtn.classList.add("button");
|
||||
controls.appendChild(configBtn);
|
||||
}
|
||||
|
||||
tr.appendChild(mod);
|
||||
tr.appendChild(spacer);
|
||||
tr.appendChild(controls);
|
||||
|
16
postinit.js
16
postinit.js
@ -22,6 +22,7 @@ globalThis.modapi_postinit = "(" + (() => {
|
||||
ModAPI.meta = {};
|
||||
ModAPI.meta._titleMap = {};
|
||||
ModAPI.meta._descriptionMap = {};
|
||||
ModAPI.meta._configMap = {};
|
||||
ModAPI.meta._developerMap = {};
|
||||
ModAPI.meta._iconMap = {};
|
||||
ModAPI.meta._versionMap = {};
|
||||
@ -78,6 +79,9 @@ globalThis.modapi_postinit = "(" + (() => {
|
||||
" - Made the mod gui open before the client starts");
|
||||
|
||||
function limitSize(x, n) {
|
||||
if (!x) {
|
||||
return "";
|
||||
}
|
||||
if (x.length > n) {
|
||||
return x.substring(0, n) + "…";
|
||||
} else {
|
||||
@ -161,6 +165,18 @@ globalThis.modapi_postinit = "(" + (() => {
|
||||
}
|
||||
ModAPI.meta._descriptionMap[document.currentScript.getAttribute("data-hash")] = limitSize(desc, 160);
|
||||
}
|
||||
ModAPI.meta.config = function (conf) {
|
||||
if (typeof conf !== "function") {
|
||||
return console.log("[ModAPIMeta] Config value was not a function");
|
||||
}
|
||||
if (!document.currentScript || document.currentScript.getAttribute("data-isMod") !== "true") {
|
||||
return console.log("[ModAPIMeta] Cannot set meta for non-mod script.");
|
||||
}
|
||||
if (!document.currentScript.hasAttribute("data-hash")) {
|
||||
return console.log("[ModAPIMeta] Script does not have a hashcode.");
|
||||
}
|
||||
ModAPI.meta._configMap[document.currentScript.getAttribute("data-hash")] = conf;
|
||||
}
|
||||
ModAPI.meta.version = function (ver) {
|
||||
if (!document.currentScript || document.currentScript.getAttribute("data-isMod") !== "true") {
|
||||
return console.log("[ModAPIMeta] Cannot set meta for non-mod script.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user