Utility function for loading Discord chunks (#2017)

This commit is contained in:
Nuckyz 2023-11-27 02:56:57 -03:00
parent 1b179f3c6d
commit 1619ee404a
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
4 changed files with 118 additions and 27 deletions

View file

@ -406,15 +406,21 @@ function runTime(token: string) {
if (method === "proxyLazyWebpack" || method === "LazyComponentWebpack") {
const [factory] = args;
result = factory();
} else if (method === "extractAndLoadChunks") {
const [code, matcher] = args;
const module = Vencord.Webpack.findModuleFactory(...code);
if (module) result = module.toString().match(matcher);
} else {
// @ts-ignore
result = Vencord.Webpack[method](...args);
}
if (result == null || ("$$get" in result && result.$$get() == null)) throw "a rock at ben shapiro";
if (result == null || ("$$vencordInternal" in result && result.$$vencordInternal() == null)) throw "a rock at ben shapiro";
} catch (e) {
let logMessage = searchType;
if (method === "find" || method === "proxyLazyWebpack" || method === "LazyComponentWebpack") logMessage += `(${args[0].toString().slice(0, 147)}...)`;
else if (method === "extractAndLoadChunks") logMessage += `([${args[0].map(arg => `"${arg}"`).join(", ")}], ${args[1].toString()})`;
else logMessage += `(${args.map(arg => `"${arg}"`).join(", ")})`;
console.log("[PUP_WEBPACK_FIND_FAIL]", logMessage);