36 lines
861 B
JavaScript
Executable File
36 lines
861 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
import puppeteer from "puppeteer-core";
|
|
|
|
const b = await Promise.race([
|
|
puppeteer.connect({
|
|
browserURL: "http://localhost:9222",
|
|
defaultViewport: null,
|
|
}),
|
|
new Promise((_, reject) => setTimeout(() => reject(new Error("timeout")), 5000)),
|
|
]).catch((e) => {
|
|
console.error("✗ Could not connect to browser:", e.message);
|
|
console.error(" Run: browser-start.js");
|
|
process.exit(1);
|
|
});
|
|
|
|
const p = (await b.pages()).at(-1);
|
|
|
|
if (!p) {
|
|
console.error("✗ No active tab found");
|
|
process.exit(1);
|
|
}
|
|
|
|
const cookies = await p.cookies();
|
|
|
|
for (const cookie of cookies) {
|
|
console.log(`${cookie.name}: ${cookie.value}`);
|
|
console.log(` domain: ${cookie.domain}`);
|
|
console.log(` path: ${cookie.path}`);
|
|
console.log(` httpOnly: ${cookie.httpOnly}`);
|
|
console.log(` secure: ${cookie.secure}`);
|
|
console.log("");
|
|
}
|
|
|
|
await b.disconnect();
|