Add CDP-only debug mode
This commit is contained in:
@@ -10,6 +10,7 @@ const sourceUrl = process.argv[2];
|
||||
const holdMs = Number(process.env.DEBUG_HOLD_MS || "900000");
|
||||
const port = Number(process.env.DEBUG_PORT || "9222");
|
||||
const proxyPort = process.env.DEBUG_PROXY_PORT ? Number(process.env.DEBUG_PROXY_PORT) : null;
|
||||
const cdpOnly = process.env.DEBUG_CDP_ONLY === "1";
|
||||
|
||||
if (!sourceUrl) {
|
||||
console.error("usage: node scripts/debug-chatgpt-share.mjs <chatgpt-share-url>");
|
||||
@@ -67,7 +68,7 @@ browserProcess = spawn(executablePath, [
|
||||
"--remote-debugging-address=0.0.0.0",
|
||||
`--remote-debugging-port=${port}`,
|
||||
`--user-data-dir=${userDataDir}`,
|
||||
"about:blank"
|
||||
cdpOnly ? sourceUrl : "about:blank"
|
||||
], {
|
||||
stdio: ["ignore", "pipe", "pipe"]
|
||||
});
|
||||
@@ -104,6 +105,13 @@ if (proxyPort) {
|
||||
console.log(`[${now()}] DevTools proxy: 0.0.0.0:${proxyPort} -> 127.0.0.1:${port}`);
|
||||
}
|
||||
|
||||
if (cdpOnly) {
|
||||
console.log(`[${now()}] CDP-only mode; holding browser for ${Math.round(holdMs / 1000)}s.`);
|
||||
await new Promise((resolve) => setTimeout(resolve, holdMs));
|
||||
await close();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
browser = await chromium.connectOverCDP(`http://127.0.0.1:${port}`);
|
||||
|
||||
context = await browser.newContext({
|
||||
|
||||
Reference in New Issue
Block a user