const { chromium } = require('playwright-core'); const fs = require('fs'); const OUT = '/data/shots'; const PAGES = [ { name: 'shadowbroker', url: 'http://127.0.0.1/', wait: 30000, dismiss: ['button[aria-label="Close"]', 'text=×', 'button:has-text("NEXT")'] }, { name: 'worldmonitor', url: 'http://127.0.0.1/wm/', wait: 35000, dismiss: ['button[aria-label="Close"]', 'text=×'] }, ]; (async () => { const browser = await chromium.launch({ executablePath: '/data/tools/chrome-headless-shell-linux64/chrome-headless-shell', args: ['--no-sandbox', '--disable-dev-shm-usage', '--use-gl=swiftshader', '--enable-unsafe-swiftshader'], }); const report = []; for (const p of PAGES) { const ctx = await browser.newContext({ viewport: { width: 1600, height: 1000 } }); const page = await ctx.newPage(); const errs = []; page.on('console', m => { if (m.type() === 'error') errs.push(m.text().slice(0, 120)); }); await page.goto(p.url, { waitUntil: 'domcontentloaded', timeout: 60000 }); await page.waitForTimeout(p.wait); for (const sel of p.dismiss) { try { const el = page.locator(sel).first(); if (await el.count() && await el.isVisible()) { await el.click({ timeout: 4000 }); await page.waitForTimeout(2500); break; } } catch (e) {} } await page.keyboard.press('Escape').catch(() => {}); await page.waitForTimeout(6000); await page.screenshot({ path: `${OUT}/${p.name}_clean.png` }); const txt = (await page.evaluate(() => document.body.innerText)).replace(/\s+/g, ' '); report.push({ name: p.name, errors: errs.length, chars: txt.length, head: txt.slice(0, 400) }); await ctx.close(); } await browser.close(); console.log(JSON.stringify(report, null, 1)); })();