From 6398dd25d20e6bc3e02425b709233066baf64e0c Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 27 Sep 2022 14:34:57 +0200 Subject: Unbrick Vencord - Pt 1 --- src/webpack/webpack.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/webpack') diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts index 27306de..a1fd2fb 100644 --- a/src/webpack/webpack.ts +++ b/src/webpack/webpack.ts @@ -32,15 +32,22 @@ export function find(filter: FilterFn, getDefault = true) { for (const key in cache) { const mod = cache[key]; - if (mod?.exports && filter(mod.exports)) + if (!mod?.exports) continue; + + if (filter(mod.exports)) return mod.exports; - if (mod?.exports?.default && filter(mod.exports.default)) + if (mod.exports.default && filter(mod.exports.default)) return getDefault ? mod.exports.default : mod.exports; + for (const nestedMod in mod.exports) { + const nested = mod.exports[nestedMod]; + if (nested && filter(nested)) return nested; + } } return null; } +// TODO fix export function findAll(filter: FilterFn, getDefault = true) { if (typeof filter !== "function") throw new Error("Invalid filter. Expected a function got", filter); -- cgit