diff --git a/index.html b/index.html index 31d159d..36202e0 100644 --- a/index.html +++ b/index.html @@ -169,9 +169,8 @@ - - + diff --git a/modgui.injector.js b/modgui.injector.js deleted file mode 100644 index c8a97dc..0000000 --- a/modgui.injector.js +++ /dev/null @@ -1,301 +0,0 @@ -globalThis.modapi_guikit = `// ModAPI GUI made by TheIdiotPlays -// https://github.com/TheIdiotPlays -(() => { - var splashes = [ - "Now with A.I.D.S (automatically injected dedicated server)", - "Only causes death 90% of the time!", - "HTML is better.", - "https://github.com/EaglerForge", - "hey you should check out https://github.com/ZXMushroom63/scratch-gui", - "99% of people stop gambling before they win big.", - "Now with free estradiol!", - "Now with H.I.V (Hyper Injected Virtual-debugger)" - ]; - var gui = \`
-
-

EaglerForge Mod Manager

-

- - {splash_msg} -

-
- Warning: installing malicious mods can delete your worlds, ip-grab you, or even download more serious malware onto your computer. The EaglerForge developers are not liable for any damage caused by the use of EaglerForge and its related tools. -
-
- - - - - - - - - - - -
- Mod - - Controls -
- -
- - - - -
- - (reload to apply changes) - - - - -
\`; - - async function fileToDataURI(file) { - return new Promise((res, rej) => { - var fr = new FileReader(); - fr.addEventListener("error", (e) => { rej(e); }); - fr.addEventListener("load", (e) => { res(fr.result); }); - fr.readAsDataURL(file); - }); - } - window.modapi_displayModGui = async function (cb) { - if (!getMods) { - return; - } - if (document.querySelector("#modapi_gui_container")) { - cb ||= document.querySelector("#modapi_gui_container")._cb; - document.querySelector("#modapi_gui_container").remove(); - } - - var element = document.createElement("div"); - - element.innerHTML = gui.replace("{splash_msg}", splashes[Math.floor(Math.random() * splashes.length)]); - - document.body.appendChild(element); - - document.querySelector("#modapi_gui_container")._cb = cb; - - var modsList = await getMods(); - var tbody = document.querySelector("#modapi_gui_container .modTable tbody"); - tbody.innerHTML = ""; - modsList.forEach((modtxt, i) => { - if (!modtxt) { return } - var hash = ModAPI.util.hashCode(modtxt); - var tr = document.createElement("tr"); - var mod = document.createElement("td"); - - if (ModAPI.meta._titleMap[hash]) { - //Mod has metadata - if (ModAPI.meta._iconMap[hash]) { - var img = document.createElement("img"); - img.style.width = "48px"; - img.style.height = "48px"; - img.style.imageRendering = "pixelated"; - img.src = ModAPI.meta._iconMap[hash]; - mod.appendChild(img); - } - var h4 = document.createElement("h4"); - h4.style.margin = 0; - h4.style.padding = 0; - h4.innerText = ModAPI.meta._titleMap[hash] + (ModAPI.meta._versionMap[hash] ? " " + ModAPI.meta._versionMap[hash] : ""); - mod.appendChild(h4); - if (ModAPI.meta._developerMap[hash]) { - var h6 = document.createElement("h6"); - h6.style.margin = 0; - h6.style.padding = 0; - h6.innerText = ModAPI.meta._developerMap[hash]; - mod.appendChild(h6); - } - if (ModAPI.meta._descriptionMap[hash]) { - var span = document.createElement("span"); - span.style.fontSize = "0.65rem"; - span.innerText = ModAPI.meta._descriptionMap[hash]; - mod.appendChild(span); - } - } else { - //Mod does not have metadata - if (modtxt.length > 125) { - try { - mod.innerText = modtxt.match(/data:text\\/\\S+?;fs=\\S+;/m)[0] - } catch (error) { - mod.innerText = "Unknown Mod."; - } - } else { mod.innerText = modtxt; } - } - - var spacer = document.createElement("td"); - spacer.classList.add("nothing"); - var controls = document.createElement("td"); - - var button = document.createElement("button"); - button.innerText = "Delete"; - button.style.height = "3rem"; - button.style.marginTop = "calc(50% - 1.5rem)"; - button.addEventListener("click", async () => { - await removeMod(i); - window.modapi_displayModGui(); - }); - button.classList.add("button"); - controls.appendChild(button); - tr.appendChild(mod); - tr.appendChild(spacer); - tr.appendChild(button); - tbody.appendChild(tr); - }); - var once = false; - if (cb) { - document.querySelector("#modapi_gui_container ._doneButton").addEventListener("mousedown", ()=>{ - if (once) { - return; - } - once = true; - cb(); - document.querySelector("#modapi_gui_container").remove(); - }) - } - } - - window.modapi_clearmods = async () => { - await resetMods(); - window.modapi_displayModGui(); - } - window.modapi_addmod = async () => { - var mod = window.prompt("Paste in the URL of the mod you wish to add: "); - if (!mod || mod.length === 0) { - return; - } - await addMod("web@" + mod); - window.modapi_displayModGui(); - } - window.modapi_uploadmod = async () => { - var f = document.createElement("input"); - f.type = "file"; - f.accept = "text/javascript"; - f.multiple = true; - f.addEventListener("input", async () => { - if (f.files.length < 1) { - return; - } - for (let i = 0; i < f.files.length; i++) { - await addMod("web@" + (await fileToDataURI(f.files[i])).replaceAll(";base64", ";fs=" + f.files[i].name + ";base64")); - } - window.modapi_displayModGui(); - }); - f.click(); - } -})(); -`; diff --git a/modgui.js b/modgui.js index 85a9a99..5ef4d75 100644 --- a/modgui.js +++ b/modgui.js @@ -1,6 +1,7 @@ -// ModAPI GUI made by TheIdiotPlays -// https://github.com/TheIdiotPlays -(() => { + +globalThis.modapi_guikit = "(" + (() => { + // ModAPI GUI made by TheIdiotPlays + // https://github.com/TheIdiotPlays var splashes = [ "Now with A.I.D.S (automatically injected dedicated server)", "Only causes death 90% of the time!", @@ -297,4 +298,4 @@ }); f.click(); } -})(); +}).toString() + ")();"; \ No newline at end of file diff --git a/postinit.async.js b/postinit.async.js deleted file mode 100644 index 656c8dc..0000000 --- a/postinit.async.js +++ /dev/null @@ -1,4 +0,0 @@ -globalThis.modapi_postinitasync = "(" + (() => { - //EaglerForge post initialization code for async. - -}).toString() + ")();"; diff --git a/postinit.js b/postinit.js index 1ac0a9f..91ed30a 100644 --- a/postinit.js +++ b/postinit.js @@ -955,6 +955,10 @@ globalThis.modapi_postinit = "(" + (() => { function qhash(txt, arr) { var interval = 4095 - arr.length; + if (interval < 1) { + console.error("[ModAPI.keygen] Ran out of IDs while generating for " + txt); + return -1; + } var x = 1; for (let i = 0; i < txt.length; i++) { x += txt.charCodeAt(i); @@ -962,7 +966,7 @@ globalThis.modapi_postinit = "(" + (() => { x = Math.abs(x); x = x % interval; } - var hash = x + arr.length; + var hash = x; while (arr.includes(hash)) { hash = (hash + 1) % (interval + arr.length); }