import { chromium } from 'playwright';
const b = await chromium.launch({ executablePath:'/usr/bin/chromium-browser', args:['--no-sandbox'] });
async function go(theme,file){
const ctx = await b.newContext({ viewport:{ width:390, height:1500 }, deviceScaleFactor:1.5, serviceWorkers:'block' });
await ctx.addInitScript((t)=>{ localStorage.setItem('sz_theme',t); localStorage.setItem('sz_accent','green'); },theme);
const p = await ctx.newPage();
await p.goto('https://poly-dev.szhub.space/', { waitUntil:'domcontentloaded', timeout:35000 });
await p.waitForTimeout(5000);
await p.click('.pk-card', { timeout: 8000 }).catch(e=>console.log('click fail',e.message));
await p.waitForTimeout(5000);
const hasProf = await p.evaluate(()=>!!document.querySelector('.pk-profile .wp-container'));
await p.screenshot({ path:file });
console.log(theme,'profile mounted:', hasProf, '| url:', p.url());
await ctx.close();
}
await go('dark','_prof_dark.png');
await go('light','_prof_light.png');
await b.close();