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)]);