← back to Delivery Address Skill
scripts/launch.js
30 lines
// Launch a long-lived headed real-Chrome session with CDP for the relay scripts.
// Usage: node launch.js --platform ubereats --user me@example.com [--port 9223]
const path = require('path');
const { chromium } = require('playwright');
const { parseArgs, loadConfig, platform } = require('./lib');
(async () => {
const args = parseArgs(process.argv);
const cfg = loadConfig();
const plat = platform(args.platform || cfg.platform);
const user = args.user || cfg.user_email;
if (!user) { console.error('Need --user <email> (or user_email in config.json)'); process.exit(2); }
const port = args.port || cfg.cdp_port || 9223;
const profile = path.join(__dirname, '..', 'profiles',
`${user.replace(/[@.]/g, '_')}-${args.platform || cfg.platform}`);
const ctx = await chromium.launchPersistentContext(profile, {
channel: 'chrome',
headless: false,
viewport: { width: 1360, height: 900 },
args: [`--remote-debugging-port=${port}`],
});
const page = ctx.pages()[0] || (await ctx.newPage());
await page.goto(plat.home, { waitUntil: 'domcontentloaded', timeout: 60000 })
.catch(e => console.log('nav err', e.message));
console.log(`READY cdp=http://127.0.0.1:${port} profile=${profile}`);
console.log('URL:', page.url());
await new Promise(() => {}); // keep alive
})().catch(e => { console.error('LAUNCH FAIL', e.message); process.exit(1); });