-
Notifications
You must be signed in to change notification settings - Fork 12
/
modgui.injector.js
301 lines (279 loc) · 9.38 KB
/
modgui.injector.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
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 = \`<div id="modapi_gui_container">
<header>
<h1 class="title">EaglerForge Mod Manager</h1>
<h4>
<!-- Now with with A.I.D.S. (automatically injected dedicated server)! -->
{splash_msg}
</h4>
<h5>
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.
</h5>
</header>
<table class="modTable">
<thead>
<tr>
<td>
Mod
</td>
<td class="nothing"></td>
<td>
Controls
</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="controls">
<button class="button" onclick="window.modapi_uploadmod()">Upload Mod (.js)</button>
<button class="button" onclick="window.modapi_addmod()">Add Mod From URL</button>
<button class="button" style="text-shadow: 0px 0px 10px rgba(255, 0, 0, 0.5)" onclick="window.modapi_clearmods()">Clear All Mods</button>
<button class="button _doneButton" onclick="this.parentElement.parentElement.remove();">Done</button>
</div>
<span>(reload to apply changes)</span>
<footer>
<p>
GUI by <a href="https://github.com/TheIdiotPlays">TheIdiotPlays</a>
</p>
<p>
Modloader linker by
<a href="https://github.com/ZXMushroom63">ZXMushroom63</a>
</p>
<p>
API by <a href="https://github.com/ZXMushroom63">ZXMushroom63,</a> <a href="https://leah.chromebooks.lol">Leah Anderson,</a> and <a href="https://github.com/radmanplays">radmanplays</a>
</p>
</footer>
<style>
#modapi_gui_container td:not(.nothing):not(:has(.button)) {
padding: 0.5rem 1.5rem;
margin: 0.5rem;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
#modapi_gui_container td.nothing {
user-select: none;
opacity: 0;
width: 5rem;
}
#modapi_gui_container td {
text-align: center;
}
#modapi_gui_container h4, #modapi_gui_container h5 {
padding-bottom: 0;
margin-bottom: 0;
}
#modapi_gui_container h5 {
color: white;
text-shadow: 0px 0px 10px rgba(255,0,0,0.5);
font-size: 0.75rem;
}
#modapi_gui_container a {
color: white;
transition: 1s;
}
#modapi_gui_container a:hover {
color: lightblue;
}
#modapi_gui_container {
overflow-y: scroll;
overflow-x: hidden;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
height: 100vh;
width: 100vw;
position: fixed;
z-index: 9999999999;
top: 0;
left: 0;
font-family: sans-serif;
background: white;
}
#modapi_gui_container header {
background-color: #333;
width: 100%;
padding: 1rem 0;
text-align: center;
color: white;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
#modapi_gui_container .title {
font-size: 3rem;
margin: 0;
font-weight: 700;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
#modapi_gui_container .controls {
display: flex;
gap: 1rem;
margin-bottom: 2rem;
flex-wrap: wrap;
justify-content: center;
width: 100%;
}
#modapi_gui_container .button {
background-color: #555;
color: white;
padding: 12px 24px;
font-size: 1rem;
font-weight: 600;
border: none;
border-radius: 2px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.2s ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
#modapi_gui_container .button:hover {
background-color: #777;
transform: translateY(-2px);
}
#modapi_gui_container footer {
width: 100%;
padding: 1rem;
background-color: #333;
text-align: center;
color: white;
font-size: 1.25rem;
box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
}
</style>
</div>\`;
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();
}
})();
`;