Wire validated core bridge, migrate daemon to it, verify live

This commit is contained in:
Fisto
2026-09-11 14:15:03 +02:00
parent e62d3007d8
commit 7d6650ce4e
27 changed files with 754 additions and 266 deletions
+55
View File
@@ -0,0 +1,55 @@
/*
* Veskslop development tool — run one expression in the real client over CDP.
*
* Use it with the client started on --remote-debugging-port=9222. The main use
* is to dispatch synthetic events for end-to-end tests.
*
* Usage:
* CDP_EXPRESSION='Vencord.Webpack.Common.FluxDispatcher.dispatch({...})' pnpm cdp:dispatch
*/
import WebSocket from "ws";
const expression = process.env.CDP_EXPRESSION;
if (!expression) {
console.error("CDP_EXPRESSION is required");
process.exit(1);
}
const cdpUrl = process.env.CDP_URL ?? "http://127.0.0.1:9222";
const targets = (await (await fetch(`${cdpUrl}/json`)).json()) as any[];
const page = targets.find(target => target.type === "page" && target.url.includes("discord.com"));
if (!page) {
console.error("No Discord page target");
process.exit(1);
}
const ws = new WebSocket(page.webSocketDebuggerUrl);
await new Promise<void>((resolve, reject) => {
ws.once("open", () => resolve());
ws.once("error", reject);
});
const response = await new Promise<any>((resolve, reject) => {
const timer = setTimeout(() => reject(new Error("CDP evaluate timed out")), 10_000);
ws.on("message", raw => {
const message = JSON.parse(raw.toString());
if (message.id !== 1) return;
clearTimeout(timer);
resolve(message);
});
ws.send(
JSON.stringify({
id: 1,
method: "Runtime.evaluate",
params: { expression, returnByValue: true, awaitPromise: true }
})
);
});
console.log(JSON.stringify(response.result ?? response.error));
ws.close();