From 681d22f28cbf6a37ac4163230ef1d56e925059fe Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Sun, 2 Mar 2025 15:08:23 +0800 Subject: [PATCH 01/13] small patches --- injector.js | 2 +- postinit.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/injector.js b/injector.js index 30b93ce..3ba5915 100644 --- a/injector.js +++ b/injector.js @@ -1,4 +1,4 @@ -globalThis.ModAPIVersion = "v2.7"; +globalThis.ModAPIVersion = "v2.7.1"; globalThis.doEaglerforge = true; document.querySelector("title").innerText = `EaglerForge Injector ${ModAPIVersion}`; document.querySelector("h1").innerText = `EaglerForge Injector ${ModAPIVersion}`; diff --git a/postinit.js b/postinit.js index 53b8868..074db62 100644 --- a/postinit.js +++ b/postinit.js @@ -771,7 +771,7 @@ globalThis.modapi_postinit = "(" + (() => { if (!object) { return null; } - if (prop in object) { + if ((prop in object) && Object.keys(object).includes(prop)) { return prop; } var possibleKeys = Object.keys(object).filter(x => { return x.startsWith(prop) }); @@ -780,7 +780,7 @@ globalThis.modapi_postinit = "(" + (() => { }) return possibleKeys.sort((a, b) => { return a.length - b.length; - })[0] || null; + })[0] || prop; } ModAPI.util.modifyFunction = function (fn, patcherFn) { From 4ea2782843b43d912f4a9217581a6ba02173a679 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Thu, 6 Mar 2025 17:15:50 +0800 Subject: [PATCH 02/13] add asdasd --- modgui.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modgui.js b/modgui.js index 3eb1d96..7d52fa1 100644 --- a/modgui.js +++ b/modgui.js @@ -10,7 +10,8 @@ globalThis.modapi_guikit = "(" + (() => { "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)" + "Now with H.I.V (Hyper Injected Virtual-debugger)", + "asdasd" ]; var gui = `
From 51980458487706529fbdb4b35c7b51a8f9a60243 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Wed, 12 Mar 2025 15:22:56 +0800 Subject: [PATCH 03/13] add new splash message --- modgui.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modgui.js b/modgui.js index 7d52fa1..95d82b6 100644 --- a/modgui.js +++ b/modgui.js @@ -11,7 +11,8 @@ globalThis.modapi_guikit = "(" + (() => { "99% of people stop gambling before they win big.", "Now with free estradiol!", "Now with H.I.V (Hyper Injected Virtual-debugger)", - "asdasd" + "asdasd", + "Star us on GitHub to support us! https://github.com/EaglerForge/EaglerForgeInjector" ]; var gui = `
From f22b7b4974395936a2b708e8043d83379b405407 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Wed, 12 Mar 2025 15:47:43 +0800 Subject: [PATCH 04/13] add background logging --- backgroundLogger.js | 32 ++++++++++++++++++++++++++++++++ index.html | 1 + injector.js | 27 +++++++++++++++++++++++---- injector.minify.js | 6 +++--- modgui.js | 3 ++- 5 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 backgroundLogger.js diff --git a/backgroundLogger.js b/backgroundLogger.js new file mode 100644 index 0000000..e2398bd --- /dev/null +++ b/backgroundLogger.js @@ -0,0 +1,32 @@ +var backgroundLogs = document.createElement("div"); +backgroundLogs.style = ` + color: lime; + opacity: 0.1; + font-family: monospace; + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + z-index: -1; + pointer-events: none; + overflow: none; + user-select: none; + `; +const bgLogsList = []; +document.documentElement.appendChild(backgroundLogs); +var dirty = true; +function backgroundLog(text, unSuppress) { + var linesExcess = backgroundLogs.scrollHeight - window.innerHeight; + for (i = 0; i < linesExcess; i++) { + bgLogsList.shift(); + } + bgLogsList.push(text); + dirty = true; + if (!unSuppress) { + return; + } + dirty = false; + backgroundLogs.innerText = bgLogsList.join("\n"); +} +backgroundLog("Awaiting input..."); \ No newline at end of file diff --git a/index.html b/index.html index 6032025..befff95 100644 --- a/index.html +++ b/index.html @@ -163,6 +163,7 @@ `; var freezeCallstack = `if(ModAPI.hooks.freezeCallstack){return false};`; + diff --git a/injector.js b/injector.js index 3ba5915..8141230 100644 --- a/injector.js +++ b/injector.js @@ -8,6 +8,7 @@ function wait(ms) { }); } function _status(x) { + backgroundLog(x, true); document.querySelector("#status").innerText = x; } function entriesToStaticVariableProxy(entries, prefix, clinitList) { @@ -77,6 +78,7 @@ async function processClasses(string) { if (!confirm("The minify step is extremely slow, especially on lower-end devices, and can take upwards of 15 minutes.")) { return; } + backgroundLog("[MINIFY] Minify warning bypassed."); } _status("Beginning patch process..."); await wait(50); @@ -101,6 +103,7 @@ var main;(function(){` "var main;\n(function() {", modapi_preinit + "var main;\n(function() {" ); + backgroundLog("[JSPATCH] Adding pre-init script"); patchedFile = patchedFile.replace( /function \$rt_metadata\(data\)( ?){/gm, `function $rt_metadata(data) { @@ -108,20 +111,21 @@ var main;(function(){` ModAPI.hooks._rippedData.push(data); /*/EaglerForge Client Patch/*/` ); - + backgroundLog("[JSPATCH] Redirecting $rt_metadata to ModAPI.hooks._rippedData"); patchedFile = patchedFile.replaceAll( `return thread != null && thread.isResuming()`, (match) => { return freezeCallstack + match; } ); - + backgroundLog("[JSPATCH] Freeze-callstack patch on TeaVMThread.isResuming()"); patchedFile = patchedFile.replaceAll( `return thread != null && thread.isSuspending();`, (match) => { return freezeCallstack + match; } ); + backgroundLog("[JSPATCH] Freeze-callstack patch on TeaVMThread.isSuspending()"); patchedFile = patchedFile.replaceAll( `return $rt_currentNativeThread;`, @@ -132,12 +136,12 @@ var main;(function(){` ); } ); + backgroundLog("[JSPATCH] Freeze-callstack patch thread getter"); patchedFile = patchedFile.replaceAll("function TeaVMThread(", "globalThis.ModAPI.hooks.TeaVMThread = TeaVMThread;\nfunction TeaVMThread("); _status("Getting clinit list..."); var clinitList = [...patchedFile.matchAll(/^[\t ]*function \S+?_\S+?_\$callClinit\(/gm)].map(x => x[0].replaceAll("function ", "").replaceAll("(", "").trim()); - console.log(clinitList); _status("Extracting constructors and methods..."); await wait(50); @@ -158,6 +162,8 @@ var main;(function(){` } ); + backgroundLog("-> Extract contructor 1"); + const extractInternalConstructorRegex = /^\s*function (\S*?)__init_\d*?\(\$this/gm; //same as extract constructor regex, but only allow $this as first argument patchedFile = patchedFile.replaceAll( @@ -172,6 +178,8 @@ var main;(function(){` } ); + backgroundLog("-> Extract contructor 2"); + const extractInstanceMethodRegex = /^[\t ]*function \S+?_\S+?_\S+?\((\$this)?/gm; // /^[\t ]*function \S+?_\S+?_\S+?\(\$this/gm const extractInstanceMethodFullNameRegex = /function (\S*?)\(/gm; // /function (\S*?)\(\$this/gm @@ -198,6 +206,10 @@ var main;(function(){` ); } ); + + backgroundLog("-> Extract instance methods"); + backgroundLog("-> Expose instance methods"); + var staticVariables = [ ...patchedFile.matchAll(/var \S+?_\S+?_\S+? = /gm), ].flatMap((x) => { @@ -205,6 +217,7 @@ var main;(function(){` }).filter(x => { return (!x.includes("$_clinit_$")) && (!x.includes("$lambda$")) }); + backgroundLog("-> Extract static variables"); //Also stores classes from $rt_classWithoutFields(0) patchedFile = patchedFile.replaceAll( /var \S+?_\S+? = \$rt_classWithoutFields\(\S*?\);/gm, @@ -240,6 +253,7 @@ var main;(function(){` ); //Edge cases. sigh //Done: add support for static properties on classes with constructors like this: function nmcg_GuiMainMenu() { + backgroundLog("-> Expose static variables"); patchedFile = patchedFile.replaceAll( @@ -307,10 +321,13 @@ var main;(function(){` \`; } - _status("[ASYNC_PLUGIN_1] Parsing html..."); + _status("[MINIFY] Parsing html..."); await wait(50); const parser = new DOMParser(); const doc = parser.parseFromString(inputHtml, 'text/html'); @@ -40,7 +40,7 @@ async function shronk(input) { for (let i = 0; i < scriptTags.length; i++) { const scriptTag = scriptTags[i]; const code = scriptTag.textContent; - _status("[ASYNC_PLUGIN_1] Transpiling script #" + (i + 1) + " of length " + Math.round(code.length / 1000) + "k..."); + _status("[MINIFY] Transpiling script #" + (i + 1) + " of length " + Math.round(code.length / 1000) + "k..."); await wait(150); @@ -51,7 +51,7 @@ async function shronk(input) { await wait(10); } - _status("[ASYNC_PLUGIN_1] Job complete!"); + _status("[MINIFY] Job complete!"); await wait(50); if (isHtml) { diff --git a/modgui.js b/modgui.js index 95d82b6..a0c0d7a 100644 --- a/modgui.js +++ b/modgui.js @@ -186,7 +186,8 @@ globalThis.modapi_guikit = "(" + (() => { 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)]); From ccdac07c0554e7130a451e010b158e80a0d9f222 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Wed, 12 Mar 2025 15:48:37 +0800 Subject: [PATCH 05/13] fix capitalisation --- injector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/injector.js b/injector.js index 8141230..fc72ec0 100644 --- a/injector.js +++ b/injector.js @@ -352,7 +352,7 @@ document.querySelector("#giveme").addEventListener("click", () => { if (globalThis.doEaglerforge) { if (string.includes("__eaglerforgeinjector_installation_flag__")) { backgroundLog("Detected input containing EFI installation flag.", true); - return alert("this file already has eaglerforge injected in it, you nonce.\nif you're trying to update, you need a vanilla file."); + return alert("this file already has EaglerForge injected in it, you nonce.\nif you're trying to update, you need a vanilla file."); } patchedFile = await processClasses(patchedFile); } else if (globalThis.doShronk) { From 711263afec42fe89a5451462887086d678041de2 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Wed, 12 Mar 2025 18:05:39 +0800 Subject: [PATCH 06/13] add minifyextras --- index.html | 8 ++++++-- injector.js | 2 +- injector.minify.js | 32 ++++++++++++++------------------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index befff95..7b73985 100644 --- a/index.html +++ b/index.html @@ -90,8 +90,12 @@ >Choose .html file...
- -     + + +     + +     +      Awaiting input...

diff --git a/injector.js b/injector.js index fc72ec0..4cb8de0 100644 --- a/injector.js +++ b/injector.js @@ -322,7 +322,7 @@ var main;(function(){` \