← back to Eur Recrawl
inspect.mjs
26 lines
// inspect.mjs <url> [authProfile] — dump inputs/buttons across all frames for a page.
import { chromium } from 'playwright';
import path from 'node:path';
const url = process.argv[2];
const profile = process.argv[3] || 'dgtrade';
if (!url) { console.error('usage: node inspect.mjs <url> [authProfile]'); process.exit(1); }
const ctx = await chromium.launchPersistentContext(path.join(process.cwd(), '.auth', profile), {
headless: false, channel: 'chrome', viewport: { width: 1440, height: 900 },
});
const page = ctx.pages()[0] || await ctx.newPage();
await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60000 }).catch((e) => console.log('nav', e.message));
await page.waitForTimeout(5000);
console.log('title:', await page.title().catch(() => ''), '| url:', page.url());
for (const fr of page.frames()) {
const els = await fr.evaluate(() =>
[...document.querySelectorAll('input, button, a[href*=login i], [type=submit]')].map((el) => ({
tag: el.tagName, type: el.type || '', name: el.name || '', id: el.id || '', ph: el.placeholder || '',
txt: (el.innerText || el.value || '').slice(0, 25),
})).filter((e) => e.type !== 'hidden'),
).catch(() => []);
if (els.length) console.log(`\n[frame ${fr.url().slice(0, 70)}]\n` + JSON.stringify(els));
}
await page.screenshot({ path: 'probe-inspect.png' }).catch(() => {});
await page.waitForTimeout(1500);
await ctx.close();