testing something

This commit is contained in:
Nuckyz 2023-11-26 21:45:05 -03:00
parent afa6318458
commit 56c7e2ca8a
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -327,9 +327,8 @@ function runTime(token: string) {
if (!chunks) throw new Error("Failed to get chunks"); if (!chunks) throw new Error("Failed to get chunks");
chunksLoop: await Promise.all(Object.keys(chunks).map(async entryPoint => {
for (const entryPoint in chunks) { const chunkIds = chunks![entryPoint];
const chunkIds = chunks[entryPoint];
for (const id of chunkIds) { for (const id of chunkIds) {
if (!wreq.u(id)) continue; if (!wreq.u(id)) continue;
@ -340,21 +339,21 @@ function runTime(token: string) {
if (isWasm) { if (isWasm) {
invalidChunks.push(id); invalidChunks.push(id);
continue chunksLoop; return;
} }
validChunks.push(id); validChunks.push(id);
} }
validChunksEntryPoints.push(entryPoint); validChunksEntryPoints.push(entryPoint);
} }));
for (const entryPoint of validChunksEntryPoints) { await Promise.all(validChunksEntryPoints.map(async entryPoint => {
try { try {
// Loads all chunks required for an entry point // Loads all chunks required for an entry point
await (wreq as any).el(entryPoint); await (wreq as any).el(entryPoint);
} catch (err) { } } catch (err) { }
} }));
const allChunks = Function("return " + (wreq.u.toString().match(/(?<=\()\{.+?\}/s)?.[0] ?? "null"))() as Record<string | number, string[]> | null; const allChunks = Function("return " + (wreq.u.toString().match(/(?<=\()\{.+?\}/s)?.[0] ?? "null"))() as Record<string | number, string[]> | null;
if (!allChunks) throw new Error("Failed to get all chunks"); if (!allChunks) throw new Error("Failed to get all chunks");
@ -362,14 +361,14 @@ function runTime(token: string) {
return !(validChunks.includes(id) || invalidChunks.includes(id)); return !(validChunks.includes(id) || invalidChunks.includes(id));
}); });
for (const id of chunksLeft) { await Promise.all(chunksLeft.map(async id => {
const isWasm = await fetch(wreq.p + wreq.u(id)) const isWasm = await fetch(wreq.p + wreq.u(id))
.then(r => r.text()) .then(r => r.text())
.then(t => t.includes(".module.wasm") || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); .then(t => t.includes(".module.wasm") || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push"));
// Loads a chunk // Loads a chunk
if (!isWasm) await wreq.e(id as any); if (!isWasm) await wreq.e(id as any);
} }));
// Make sure every chunk has finished loading // Make sure every chunk has finished loading
await new Promise(r => setTimeout(r, 1000)); await new Promise(r => setTimeout(r, 1000));