From 3704c71ae1f37e4a3cd4dd3f24ad0acf78bb5d98 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:46:48 -0300 Subject: [PATCH 1/2] Fix loading scientific notation chunks --- src/debug/loadLazyChunks.ts | 18 +++++++++--------- src/webpack/webpack.ts | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts index 64c3e0ead..d3484bd9a 100644 --- a/src/debug/loadLazyChunks.ts +++ b/src/debug/loadLazyChunks.ts @@ -15,9 +15,9 @@ export async function loadLazyChunks() { try { LazyChunkLoaderLogger.log("Loading all chunks..."); - const validChunks = new Set(); - const invalidChunks = new Set(); - const deferredRequires = new Set(); + const validChunks = new Set(); + const invalidChunks = new Set(); + const deferredRequires = new Set(); let chunksSearchingResolve: (value: void | PromiseLike) => void; const chunksSearchingDone = new Promise(r => chunksSearchingResolve = r); @@ -29,14 +29,14 @@ export async function loadLazyChunks() { async function searchAndLoadLazyChunks(factoryCode: string) { const lazyChunks = factoryCode.matchAll(LazyChunkRegex); - const validChunkGroups = new Set<[chunkIds: string[], entryPoint: string]>(); + const validChunkGroups = new Set<[chunkIds: number[], entryPoint: number]>(); // Workaround for a chunk that depends on the ChannelMessage component but may be be force loaded before // the chunk containing the component const shouldForceDefer = factoryCode.includes(".Messages.GUILD_FEED_UNFEATURE_BUTTON_TEXT"); await Promise.all(Array.from(lazyChunks).map(async ([, rawChunkIds, entryPoint]) => { - const chunkIds = rawChunkIds ? Array.from(rawChunkIds.matchAll(Webpack.ChunkIdsRegex)).map(m => m[1]) : []; + const chunkIds = rawChunkIds ? Array.from(rawChunkIds.matchAll(Webpack.ChunkIdsRegex)).map(m => Number(m[1])) : []; if (chunkIds.length === 0) { return; @@ -61,7 +61,7 @@ export async function loadLazyChunks() { } if (!invalidChunkGroup) { - validChunkGroups.add([chunkIds, entryPoint]); + validChunkGroups.add([chunkIds, Number(entryPoint)]); } })); @@ -131,14 +131,14 @@ export async function loadLazyChunks() { } // All chunks Discord has mapped to asset files, even if they are not used anymore - const allChunks = [] as string[]; + const allChunks = [] as number[]; // Matches "id" or id: - for (const currentMatch of wreq!.u.toString().matchAll(/(?:"(\d+?)")|(?:(\d+?):)/g)) { + for (const currentMatch of wreq!.u.toString().matchAll(/(?:"([\deE]+?)")|(?:([\deE]+?):)/g)) { const id = currentMatch[1] ?? currentMatch[2]; if (id == null) continue; - allChunks.push(id); + allChunks.push(Number(id)); } if (allChunks.length === 0) throw new Error("Failed to get all chunks"); diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index f21a38d67..272ecd94f 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -544,7 +544,7 @@ export async function extractAndLoadChunks(code: CodeFilter, matcher: RegExp = D } if (rawChunkIds) { - const chunkIds = Array.from(rawChunkIds.matchAll(ChunkIdsRegex)).map((m: any) => m[1]); + const chunkIds = Array.from(rawChunkIds.matchAll(ChunkIdsRegex)).map((m: any) => Number(m[1])); await Promise.all(chunkIds.map(id => wreq.e(id))); } @@ -559,7 +559,7 @@ export async function extractAndLoadChunks(code: CodeFilter, matcher: RegExp = D return false; } - wreq(entryPointId); + wreq(Number(entryPointId)); return true; } From 01bd41413dd3bb83e0f392e7e04e9a6174d6ebda Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 19 Jul 2024 00:57:03 -0300 Subject: [PATCH 2/2] FriendsSince: Fix broken patch --- src/plugins/friendsSince/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/friendsSince/index.tsx b/src/plugins/friendsSince/index.tsx index 717bd754c..44be8927f 100644 --- a/src/plugins/friendsSince/index.tsx +++ b/src/plugins/friendsSince/index.tsx @@ -52,7 +52,7 @@ export default definePlugin({ { find: ".PANEL}),nicknameIcons", replacement: { - match: /USER_PROFILE_MEMBER_SINCE,.{0,100}userId:(\i\.id)}\)}\)/, + match: /BOT_PROFILE_CREATED_ON,.{0,100}userId:(\i\.id)}\)}\)/, replace: "$&,$self.friendsSinceNew({userId:$1,isSidebar:true})" } },