// 全站 bg-brand-section 扫描:量化“满幅饱和红面”在哪些路由仍存在。 // 只读 3100 本地产物;不截图、不写远端。 import fs from 'fs'; import { chromium } from 'playwright'; const BASE = (process.env.BASE || 'http://127.0.0.1:3100').replace(/\/$/, ''); const EV = process.env.EV || 'docs/acceptance/2026-10-24-full-qa'; const routes = JSON.parse(fs.readFileSync(`${EV}/routes.json`, 'utf8')).routes; const browser = await chromium.launch(); const page = await browser.newPage({ viewport: { width: 1440, height: 900 }, reducedMotion: 'reduce' }); const out = []; for (const route of routes) { await page.goto(BASE + route, { waitUntil: 'domcontentloaded', timeout: 45000 }); await page.waitForTimeout(400); const found = await page.evaluate(() => { const els = [...document.querySelectorAll('.bg-brand-section, [class*="bg-brand-section"]')]; const docH = document.documentElement.scrollHeight || 1; return els.map((el) => { const r = el.getBoundingClientRect(); const s = getComputedStyle(el); return { tag: el.tagName, cls: String(el.className || '').slice(0, 160), text: (el.innerText || '').trim().slice(0, 80), w: Math.round(r.width), h: Math.round(r.height), top: Math.round(r.top + window.scrollY), opacity: s.opacity, bg: s.backgroundColor, pageRatio: +(r.width * r.height / (window.innerWidth * docH)).toFixed(4), }; }); }); out.push({ route, count: found.length, elements: found }); console.log(`${route} count=${found.length} ${found.map((f) => `${f.w}x${f.h}@${f.top}`).join(' ')}`); } await browser.close(); fs.writeFileSync(`${EV}/visual/bg-brand-section.json`, JSON.stringify(out, null, 2)); console.log('DONE routes=' + out.length + ' hits=' + out.filter((x) => x.count > 0).length);