const { chromium }=require('playwright-core'); const C=process.env.PORTAL_COOKIE; (async()=>{ const b=await chromium.connectOverCDP('http://127.0.0.1:9222'); for(const [w,h] of [[1280,720],[1280,600],[1024,600],[900,520],[768,600],[390,780]]){ const ctx=await b.newContext({ignoreHTTPSErrors:true,viewport:{width:w,height:h}}); await ctx.addCookies([{name:'portal_session',value:C,domain:'.example.com',path:'/',httpOnly:true,secure:true,sameSite:'Lax'}]); const p=await ctx.newPage(); await p.emulateMedia({colorScheme:'dark'}); await p.addInitScript(()=>localStorage.removeItem('navi-theme')); await p.goto('https://dashy.example.com/minimal',{waitUntil:'networkidle',timeout:90000}); await p.waitForTimeout(1800); const r=await p.evaluate(()=>{ const de=document.documentElement; const foot=document.querySelector('.navi-footer'); const fr=foot?foot.getBoundingClientRect():null; // 谁在撑高页面 let worst=null; for(const e of document.querySelectorAll('body *')){ const b=e.getBoundingClientRect(); if(b.height<4) continue; if(de.scrollHeight>innerHeight+2 && b.bottom>innerHeight+2){ if(!worst||b.bottom>worst.bottom) worst={cls:e.className.toString().slice(0,60),bottom:Math.round(b.bottom),h:Math.round(b.height)}; } } return {scrollH:de.scrollHeight,viewH:innerHeight,overflow:de.scrollHeight-innerHeight,scrollable:de.scrollHeight>innerHeight+2, bodyH:document.body.scrollHeight,footerBottom:fr?Math.round(fr.bottom):null,worst}; }); console.log(`${String(w).padStart(4)}x${String(h).padEnd(4)} docH=${String(r.scrollH).padEnd(5)} viewH=${String(r.viewH).padEnd(5)} 溢出=${String(r.overflow).padEnd(4)} 可滚=${r.scrollable?'YES':'no '} footer底=${r.footerBottom} 元凶=${r.worst?JSON.stringify(r.worst):'无'}`); await p.screenshot({path:`/tmp/mini-${w}x${h}.png`}); await ctx.close(); } await b.close(); })().catch(e=>{console.error(e);process.exit(1)});