import { chromium } from 'playwright'; const b = await chromium.launch(); const ctx = await b.newContext({ viewport:{width:1280,height:900} }); const p = await ctx.newPage(); const cdp = await ctx.newCDPSession(p); await cdp.send('Network.enable'); await cdp.send('Network.setCacheDisabled', { cacheDisabled: true }); await cdp.send('Network.emulateNetworkConditions', { offline:false, latency:150, downloadThroughput: 900*1024/8, uploadThroughput: 400*1024/8 }); const t0 = Date.now(); const samples = []; const seen = new Set(); p.on('response', r => { if (r.url().includes('/about')) seen.add(`${r.status()} ${r.url()}`); }); const nav = p.goto('https://www.novalon.cn/about', { waitUntil:'commit', timeout:90000 }).catch(()=>null); for (let i=0;i<80;i++) { const s = await p.evaluate(() => { const h1 = document.querySelector('h1'); const html = document.documentElement; // 找包住 main 的 motion wrapper 的 opacity const main = document.querySelector('main'); let wrap = main?.parentElement, wrapOp = null; while (wrap && wrap !== document.body) { const o = getComputedStyle(wrap).opacity; if (o !== '1') { wrapOp = o; break; } wrap = wrap.parentElement; } return { t: Math.round(performance.now()), body: document.body ? document.body.innerHTML.length : -1, h1op: h1 ? Number(getComputedStyle(h1).opacity) : null, wrapOp, textLen: document.body ? (document.body.innerText||'').trim().length : -1 }; }).catch(()=>null); if (s) samples.push(s); await p.waitForTimeout(120); if (s && s.h1op === 1 && s.textLen > 800) break; } await nav; console.log('responses', JSON.stringify([...seen])); const firstText = samples.find(s=>s.textLen>500); const firstVisible = samples.find(s=>s.h1op===1 && s.textLen>800); console.log('TTFB-ish 首个有文字样本:', firstText ? `${firstText.t}ms len=${firstText.textLen} wrapOp=${firstText.wrapOp} h1op=${firstText.h1op}` : 'none'); console.log('首个 h1 完全不透样本:', firstVisible ? `${firstVisible.t}ms` : 'none'); console.log('样本前 6 条:', JSON.stringify(samples.slice(0,6))); await b.close();