2022-11-11 06:37:37 -05:00
|
|
|
/*
|
|
|
|
* Vencord, a modification for Discord's desktop app
|
|
|
|
* Copyright (c) 2022 Vendicated and contributors
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// eslint-disable-next-line spaced-comment
|
|
|
|
/// <reference types="../src/globals" />
|
|
|
|
// eslint-disable-next-line spaced-comment
|
|
|
|
/// <reference types="../src/modules" />
|
|
|
|
|
|
|
|
import { readFileSync } from "fs";
|
2022-11-11 07:06:04 -05:00
|
|
|
import pup, { JSHandle } from "puppeteer-core";
|
|
|
|
|
|
|
|
for (const variable of ["DISCORD_TOKEN", "CHROMIUM_BIN"]) {
|
|
|
|
if (!process.env[variable]) {
|
|
|
|
console.error(`Missing environment variable ${variable}`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
}
|
2022-11-11 06:37:37 -05:00
|
|
|
|
2022-12-19 20:59:16 -05:00
|
|
|
const CANARY = process.env.USE_CANARY === "true";
|
|
|
|
|
2022-11-11 06:37:37 -05:00
|
|
|
const browser = await pup.launch({
|
2023-11-24 19:32:21 -05:00
|
|
|
headless: "new",
|
2022-11-11 07:06:04 -05:00
|
|
|
executablePath: process.env.CHROMIUM_BIN
|
2022-11-11 06:37:37 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
const page = await browser.newPage();
|
2022-12-19 20:59:16 -05:00
|
|
|
await page.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36");
|
2022-11-11 06:37:37 -05:00
|
|
|
|
|
|
|
function maybeGetError(handle: JSHandle) {
|
|
|
|
return (handle as JSHandle<Error>)?.getProperty("message")
|
|
|
|
.then(m => m.jsonValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
const report = {
|
|
|
|
badPatches: [] as {
|
|
|
|
plugin: string;
|
|
|
|
type: string;
|
|
|
|
id: string;
|
|
|
|
match: string;
|
|
|
|
error?: string;
|
|
|
|
}[],
|
|
|
|
badStarts: [] as {
|
|
|
|
plugin: string;
|
|
|
|
error: string;
|
|
|
|
}[],
|
2023-11-24 19:32:21 -05:00
|
|
|
otherErrors: [] as string[],
|
|
|
|
badWebpackFinds: [] as string[]
|
2022-11-11 06:37:37 -05:00
|
|
|
};
|
|
|
|
|
2023-10-21 11:51:07 -04:00
|
|
|
const IGNORED_DISCORD_ERRORS = [
|
|
|
|
"KeybindStore: Looking for callback action",
|
|
|
|
"Unable to process domain list delta: Client revision number is null",
|
|
|
|
"Downloading the full bad domains file",
|
2023-11-24 19:32:21 -05:00
|
|
|
/\[GatewaySocket\].{0,110}Cannot access '/,
|
|
|
|
"search for 'name' in undefined"
|
2023-10-21 11:51:07 -04:00
|
|
|
] as Array<string | RegExp>;
|
|
|
|
|
2022-11-11 06:37:37 -05:00
|
|
|
function toCodeBlock(s: string) {
|
|
|
|
s = s.replace(/```/g, "`\u200B`\u200B`");
|
|
|
|
return "```" + s + " ```";
|
|
|
|
}
|
|
|
|
|
2022-11-11 07:27:44 -05:00
|
|
|
async function printReport() {
|
2023-11-24 19:32:21 -05:00
|
|
|
console.log();
|
|
|
|
|
2022-12-19 20:59:16 -05:00
|
|
|
console.log("# Vencord Report" + (CANARY ? " (Canary)" : ""));
|
2023-11-24 19:32:21 -05:00
|
|
|
|
2022-11-11 06:37:37 -05:00
|
|
|
console.log();
|
|
|
|
|
|
|
|
console.log("## Bad Patches");
|
|
|
|
report.badPatches.forEach(p => {
|
|
|
|
console.log(`- ${p.plugin} (${p.type})`);
|
|
|
|
console.log(` - ID: \`${p.id}\``);
|
|
|
|
console.log(` - Match: ${toCodeBlock(p.match)}`);
|
|
|
|
if (p.error) console.log(` - Error: ${toCodeBlock(p.error)}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log();
|
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
console.log("## Bad Webpack Finds");
|
|
|
|
report.badWebpackFinds.forEach(p => console.log("- " + p));
|
|
|
|
|
|
|
|
console.log();
|
|
|
|
|
2022-11-11 06:37:37 -05:00
|
|
|
console.log("## Bad Starts");
|
|
|
|
report.badStarts.forEach(p => {
|
|
|
|
console.log(`- ${p.plugin}`);
|
|
|
|
console.log(` - Error: ${toCodeBlock(p.error)}`);
|
|
|
|
});
|
2022-11-11 07:06:04 -05:00
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
console.log();
|
|
|
|
|
2023-10-21 11:51:07 -04:00
|
|
|
report.otherErrors = report.otherErrors.filter(e => !IGNORED_DISCORD_ERRORS.some(regex => e.match(regex)));
|
|
|
|
|
2022-11-11 07:06:04 -05:00
|
|
|
console.log("## Discord Errors");
|
|
|
|
report.otherErrors.forEach(e => {
|
|
|
|
console.log(`- ${toCodeBlock(e)}`);
|
|
|
|
});
|
2022-11-11 07:27:44 -05:00
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
console.log();
|
|
|
|
|
2022-11-11 07:27:44 -05:00
|
|
|
if (process.env.DISCORD_WEBHOOK) {
|
|
|
|
await fetch(process.env.DISCORD_WEBHOOK, {
|
|
|
|
method: "POST",
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json"
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
description: "Here's the latest Vencord Report!",
|
2022-12-19 20:59:16 -05:00
|
|
|
username: "Vencord Reporter" + (CANARY ? " (Canary)" : ""),
|
2023-11-24 19:32:21 -05:00
|
|
|
avatar_url: "https://cdn.discordapp.com/icons/1015060230222131221/6101cff21e241cebb60c4a01563d0c01.webp?size=512",
|
2022-11-11 07:27:44 -05:00
|
|
|
embeds: [
|
|
|
|
{
|
|
|
|
title: "Bad Patches",
|
|
|
|
description: report.badPatches.map(p => {
|
|
|
|
const lines = [
|
|
|
|
`**__${p.plugin} (${p.type}):__**`,
|
|
|
|
`ID: \`${p.id}\``,
|
|
|
|
`Match: ${toCodeBlock(p.match)}`
|
|
|
|
];
|
|
|
|
if (p.error) lines.push(`Error: ${toCodeBlock(p.error)}`);
|
|
|
|
return lines.join("\n");
|
|
|
|
}).join("\n\n") || "None",
|
|
|
|
color: report.badPatches.length ? 0xff0000 : 0x00ff00
|
|
|
|
},
|
2023-11-24 19:32:21 -05:00
|
|
|
{
|
|
|
|
title: "Bad Webpack Finds",
|
|
|
|
description: report.badWebpackFinds.map(toCodeBlock).join("\n") || "None",
|
|
|
|
color: report.badWebpackFinds.length ? 0xff0000 : 0x00ff00
|
|
|
|
},
|
2022-11-11 07:27:44 -05:00
|
|
|
{
|
|
|
|
title: "Bad Starts",
|
|
|
|
description: report.badStarts.map(p => {
|
|
|
|
const lines = [
|
|
|
|
`**__${p.plugin}:__**`,
|
|
|
|
toCodeBlock(p.error)
|
|
|
|
];
|
|
|
|
return lines.join("\n");
|
|
|
|
}
|
|
|
|
).join("\n\n") || "None",
|
|
|
|
color: report.badStarts.length ? 0xff0000 : 0x00ff00
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Discord Errors",
|
2023-04-30 09:34:38 -04:00
|
|
|
description: report.otherErrors.length ? toCodeBlock(report.otherErrors.join("\n")) : "None",
|
2022-11-11 07:27:44 -05:00
|
|
|
color: report.otherErrors.length ? 0xff0000 : 0x00ff00
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
}).then(res => {
|
|
|
|
if (!res.ok) console.error(`Webhook failed with status ${res.status}`);
|
|
|
|
else console.error("Posted to Discord Webhook successfully");
|
|
|
|
});
|
|
|
|
}
|
2022-11-11 06:37:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
page.on("console", async e => {
|
|
|
|
const level = e.type();
|
2023-11-24 19:32:21 -05:00
|
|
|
const rawArgs = e.args();
|
2022-11-11 06:37:37 -05:00
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
const firstArg = await rawArgs[0]?.jsonValue();
|
|
|
|
if (firstArg === "[PUPPETEER_TEST_DONE_SIGNAL]") {
|
2022-11-11 06:37:37 -05:00
|
|
|
await browser.close();
|
2022-11-11 07:27:44 -05:00
|
|
|
await printReport();
|
2022-11-11 06:37:37 -05:00
|
|
|
process.exit();
|
|
|
|
}
|
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
const isVencord = firstArg === "[Vencord]";
|
|
|
|
const isDebug = firstArg === "[PUP_DEBUG]";
|
|
|
|
const isWebpackFindFail = firstArg === "[PUP_WEBPACK_FIND_FAIL]";
|
2022-11-11 07:06:04 -05:00
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
if (isWebpackFindFail) {
|
2022-11-11 06:37:37 -05:00
|
|
|
process.exitCode = 1;
|
2023-11-24 19:32:21 -05:00
|
|
|
report.badWebpackFinds.push(await rawArgs[1].jsonValue() as string);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isVencord) {
|
|
|
|
const args = await Promise.all(e.args().map(a => a.jsonValue()));
|
2022-11-11 06:37:37 -05:00
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
const [, tag, message] = args as Array<string>;
|
|
|
|
const cause = await maybeGetError(e.args()[3]);
|
2022-11-11 06:37:37 -05:00
|
|
|
|
|
|
|
switch (tag) {
|
|
|
|
case "WebpackInterceptor:":
|
2023-11-24 19:32:21 -05:00
|
|
|
process.exitCode = 1;
|
|
|
|
|
|
|
|
const [, plugin, type, id, regex] = message.match(/Patch by (.+?) (had no effect|errored|found no module) \(Module id is (.+?)\): (.+)/)!;
|
2022-11-11 06:37:37 -05:00
|
|
|
report.badPatches.push({
|
|
|
|
plugin,
|
|
|
|
type,
|
|
|
|
id,
|
2023-09-05 22:14:27 -04:00
|
|
|
match: regex.replace(/\[A-Za-z_\$\]\[\\w\$\]\*/g, "\\i"),
|
2022-11-11 06:37:37 -05:00
|
|
|
error: cause
|
|
|
|
});
|
2023-11-24 19:32:21 -05:00
|
|
|
|
2022-11-11 06:37:37 -05:00
|
|
|
break;
|
|
|
|
case "PluginManager:":
|
2023-11-24 19:32:21 -05:00
|
|
|
const failedToStartMatch = message.match(/Failed to start (.+)/);
|
|
|
|
if (!failedToStartMatch) break;
|
|
|
|
|
|
|
|
process.exitCode = 1;
|
|
|
|
|
|
|
|
const [, name] = failedToStartMatch;
|
2022-11-11 06:37:37 -05:00
|
|
|
report.badStarts.push({
|
|
|
|
plugin: name,
|
|
|
|
error: cause
|
|
|
|
});
|
2023-11-24 19:32:21 -05:00
|
|
|
|
2022-11-11 06:37:37 -05:00
|
|
|
break;
|
|
|
|
}
|
2023-11-24 19:32:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isDebug) {
|
2023-11-24 20:51:19 -05:00
|
|
|
console.error(e.text());
|
2022-11-11 06:37:37 -05:00
|
|
|
} else if (level === "error") {
|
2023-04-17 20:54:22 -04:00
|
|
|
const text = await Promise.all(
|
|
|
|
e.args().map(async a => {
|
|
|
|
try {
|
|
|
|
return await maybeGetError(a) || await a.jsonValue();
|
|
|
|
} catch (e) {
|
|
|
|
return a.toString();
|
|
|
|
}
|
|
|
|
})
|
2023-05-01 03:26:27 -04:00
|
|
|
).then(a => a.join(" ").trim());
|
2023-04-17 20:54:22 -04:00
|
|
|
|
2023-05-01 03:26:27 -04:00
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
if (text.length && !text.startsWith("Failed to load resource: the server responded with a status of") && !text.includes("found no module Filter:")) {
|
|
|
|
console.error("[Unexpected Error]", text);
|
2023-02-01 08:13:55 -05:00
|
|
|
report.otherErrors.push(text);
|
|
|
|
}
|
2022-11-11 06:37:37 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
page.on("error", e => console.error("[Error]", e));
|
|
|
|
page.on("pageerror", e => console.error("[Page Error]", e));
|
|
|
|
|
|
|
|
await page.setBypassCSP(true);
|
|
|
|
|
|
|
|
function runTime(token: string) {
|
2023-11-24 19:32:21 -05:00
|
|
|
console.log("[PUP_DEBUG]", "Starting test...");
|
2022-11-11 07:06:04 -05:00
|
|
|
|
|
|
|
try {
|
2023-11-24 19:32:21 -05:00
|
|
|
// Spoof languages to not be suspicious
|
2022-11-11 07:06:04 -05:00
|
|
|
Object.defineProperty(navigator, "languages", {
|
|
|
|
get: function () {
|
|
|
|
return ["en-US", "en"];
|
|
|
|
},
|
2022-11-11 06:37:37 -05:00
|
|
|
});
|
|
|
|
|
2022-11-11 07:06:04 -05:00
|
|
|
// Monkey patch Logger to not log with custom css
|
2023-02-01 08:13:55 -05:00
|
|
|
// @ts-ignore
|
2022-11-11 07:06:04 -05:00
|
|
|
Vencord.Util.Logger.prototype._log = function (level, levelColor, args) {
|
|
|
|
if (level === "warn" || level === "error")
|
|
|
|
console[level]("[Vencord]", this.name + ":", ...args);
|
|
|
|
};
|
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
// Force enable all plugins and patches
|
2022-11-11 07:06:04 -05:00
|
|
|
Vencord.Plugins.patches.length = 0;
|
|
|
|
Object.values(Vencord.Plugins.plugins).forEach(p => {
|
2023-01-06 21:28:40 -05:00
|
|
|
// Needs native server to run
|
|
|
|
if (p.name === "WebRichPresence (arRPC)") return;
|
|
|
|
|
2023-04-30 09:34:38 -04:00
|
|
|
Vencord.Settings.plugins[p.name].enabled = true;
|
2022-11-11 07:06:04 -05:00
|
|
|
p.patches?.forEach(patch => {
|
|
|
|
patch.plugin = p.name;
|
|
|
|
delete patch.predicate;
|
2023-11-24 19:32:21 -05:00
|
|
|
|
2022-11-11 07:06:04 -05:00
|
|
|
if (!Array.isArray(patch.replacement))
|
|
|
|
patch.replacement = [patch.replacement];
|
2023-11-24 19:32:21 -05:00
|
|
|
|
|
|
|
patch.replacement.forEach(r => {
|
|
|
|
delete r.predicate;
|
|
|
|
});
|
|
|
|
|
2022-11-11 07:06:04 -05:00
|
|
|
Vencord.Plugins.patches.push(patch);
|
|
|
|
});
|
|
|
|
});
|
2022-11-11 06:37:37 -05:00
|
|
|
|
2022-11-11 07:06:04 -05:00
|
|
|
Vencord.Webpack.waitFor(
|
|
|
|
"loginToken",
|
|
|
|
m => {
|
2023-11-24 19:32:21 -05:00
|
|
|
console.log("[PUP_DEBUG]", "Logging in with token...");
|
2022-11-11 07:06:04 -05:00
|
|
|
m.loginToken(token);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
// Force load all chunks
|
2022-11-11 07:06:04 -05:00
|
|
|
Vencord.Webpack.onceReady.then(() => setTimeout(async () => {
|
2023-11-24 19:32:21 -05:00
|
|
|
console.log("[PUP_DEBUG]", "Webpack is ready!");
|
2022-11-11 07:06:04 -05:00
|
|
|
|
|
|
|
const { wreq } = Vencord.Webpack;
|
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
console.log("[PUP_DEBUG]", "Loading all chunks...");
|
|
|
|
|
|
|
|
let chunks = null as Record<number, string[]> | null;
|
|
|
|
const sym = Symbol("Vencord.chunksExtract");
|
|
|
|
|
|
|
|
Object.defineProperty(Object.prototype, sym, {
|
|
|
|
get() {
|
|
|
|
chunks = this;
|
|
|
|
},
|
|
|
|
set() { },
|
|
|
|
configurable: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
await (wreq as any).el(sym);
|
|
|
|
delete Object.prototype[sym];
|
|
|
|
|
|
|
|
const validChunksEntryPoints = [] as string[];
|
|
|
|
const validChunks = [] as string[];
|
|
|
|
const invalidChunks = [] as string[];
|
|
|
|
|
|
|
|
if (!chunks) throw new Error("Failed to get chunks");
|
|
|
|
|
2023-11-26 19:45:05 -05:00
|
|
|
await Promise.all(Object.keys(chunks).map(async entryPoint => {
|
|
|
|
const chunkIds = chunks![entryPoint];
|
2023-11-24 19:32:21 -05:00
|
|
|
|
|
|
|
for (const id of chunkIds) {
|
|
|
|
if (!wreq.u(id)) continue;
|
|
|
|
|
|
|
|
const isWasm = await fetch(wreq.p + wreq.u(id))
|
|
|
|
.then(r => r.text())
|
|
|
|
.then(t => t.includes(".module.wasm") || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push"));
|
|
|
|
|
|
|
|
if (isWasm) {
|
|
|
|
invalidChunks.push(id);
|
2023-11-26 19:45:05 -05:00
|
|
|
return;
|
2023-11-24 19:32:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
validChunks.push(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
validChunksEntryPoints.push(entryPoint);
|
2023-11-26 19:45:05 -05:00
|
|
|
}));
|
2023-11-24 19:32:21 -05:00
|
|
|
|
2023-11-26 19:45:05 -05:00
|
|
|
await Promise.all(validChunksEntryPoints.map(async entryPoint => {
|
2023-11-24 19:32:21 -05:00
|
|
|
try {
|
|
|
|
// Loads all chunks required for an entry point
|
|
|
|
await (wreq as any).el(entryPoint);
|
|
|
|
} catch (err) { }
|
2023-11-26 19:45:05 -05:00
|
|
|
}));
|
2023-11-24 19:32:21 -05:00
|
|
|
|
|
|
|
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");
|
|
|
|
const chunksLeft = Object.keys(allChunks).filter(id => {
|
|
|
|
return !(validChunks.includes(id) || invalidChunks.includes(id));
|
|
|
|
});
|
|
|
|
|
2023-11-26 19:45:05 -05:00
|
|
|
await Promise.all(chunksLeft.map(async id => {
|
2022-11-11 07:06:04 -05:00
|
|
|
const isWasm = await fetch(wreq.p + wreq.u(id))
|
|
|
|
.then(r => r.text())
|
2023-08-11 19:35:15 -04:00
|
|
|
.then(t => t.includes(".module.wasm") || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push"));
|
2022-11-11 07:06:04 -05:00
|
|
|
|
2023-11-24 19:32:21 -05:00
|
|
|
// Loads a chunk
|
|
|
|
if (!isWasm) await wreq.e(id as any);
|
2023-11-26 19:45:05 -05:00
|
|
|
}));
|
2023-11-24 19:32:21 -05:00
|
|
|
|
|
|
|
// Make sure every chunk has finished loading
|
|
|
|
await new Promise(r => setTimeout(r, 1000));
|
|
|
|
|
|
|
|
for (const entryPoint of validChunksEntryPoints) {
|
|
|
|
try {
|
|
|
|
if (wreq.m[entryPoint]) wreq(entryPoint as any);
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log("[PUP_DEBUG]", "Finished loading all chunks!");
|
2022-11-11 07:06:04 -05:00
|
|
|
|
|
|
|
for (const patch of Vencord.Plugins.patches) {
|
2022-11-11 13:01:01 -05:00
|
|
|
if (!patch.all) {
|
|
|
|
new Vencord.Util.Logger("WebpackInterceptor").warn(`Patch by ${patch.plugin} found no module (Module id is -): ${patch.find}`);
|
|
|
|
}
|
2022-11-11 07:06:04 -05:00
|
|
|
}
|
2023-11-24 19:32:21 -05:00
|
|
|
|
|
|
|
for (const [searchType, args] of Vencord.Webpack.lazyWebpackSearchHistory) {
|
|
|
|
let method = searchType;
|
|
|
|
|
|
|
|
if (searchType === "findComponent") method = "find";
|
|
|
|
if (searchType === "findExportedComponent") method = "findByProps";
|
|
|
|
if (searchType === "waitFor" || searchType === "waitForComponent" || searchType === "waitForStore") {
|
|
|
|
if (typeof args[0] === "string") method = "findByProps";
|
|
|
|
else method = "find";
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
let result: any;
|
|
|
|
|
|
|
|
if (method === "proxyLazyWebpack" || method === "LazyComponentWebpack") {
|
|
|
|
const [factory] = args;
|
|
|
|
result = factory();
|
2023-11-25 17:50:14 -05:00
|
|
|
} else if (method === "extractAndLoadChunks") {
|
|
|
|
const [code, matcher] = args;
|
|
|
|
|
2023-11-26 19:42:37 -05:00
|
|
|
const module = Vencord.Webpack.findModuleFactory(...code);
|
2023-11-25 17:50:14 -05:00
|
|
|
if (module) result = module.toString().match(matcher);
|
2023-11-24 19:32:21 -05:00
|
|
|
} else {
|
|
|
|
// @ts-ignore
|
|
|
|
result = Vencord.Webpack[method](...args);
|
|
|
|
}
|
|
|
|
|
2023-11-25 17:50:14 -05:00
|
|
|
if (result == null || ("$$vencordInternal" in result && result.$$vencordInternal() == null)) throw "a rock at ben shapiro";
|
2023-11-24 19:32:21 -05:00
|
|
|
} catch (e) {
|
|
|
|
let logMessage = searchType;
|
|
|
|
if (method === "find" || method === "proxyLazyWebpack" || method === "LazyComponentWebpack") logMessage += `(${args[0].toString().slice(0, 147)}...)`;
|
2023-11-25 17:50:14 -05:00
|
|
|
else if (method === "extractAndLoadChunks") logMessage += `([${args[0].map(arg => `"${arg}"`).join(", ")}], ${args[1].toString()})`;
|
2023-11-24 19:32:21 -05:00
|
|
|
else logMessage += `(${args.map(arg => `"${arg}"`).join(", ")})`;
|
|
|
|
|
|
|
|
console.log("[PUP_WEBPACK_FIND_FAIL]", logMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(() => console.log("[PUPPETEER_TEST_DONE_SIGNAL]"), 1000);
|
2022-11-11 07:06:04 -05:00
|
|
|
}, 1000));
|
|
|
|
} catch (e) {
|
2023-11-24 19:32:21 -05:00
|
|
|
console.log("[PUP_DEBUG]", "A fatal error occurred:", e);
|
2022-11-11 07:06:04 -05:00
|
|
|
process.exit(1);
|
|
|
|
}
|
2022-11-11 06:37:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
await page.evaluateOnNewDocument(`
|
|
|
|
${readFileSync("./dist/browser.js", "utf-8")}
|
|
|
|
|
|
|
|
;(${runTime.toString()})(${JSON.stringify(process.env.DISCORD_TOKEN)});
|
|
|
|
`);
|
|
|
|
|
2022-12-19 20:59:16 -05:00
|
|
|
await page.goto(CANARY ? "https://canary.discord.com/login" : "https://discord.com/login");
|