import asyncio,re
from playwright.async_api import async_playwright
exec(re.search(r"^TH=.*$",open('shoot.py').read(),re.M).group(0))
async def m():
  async with async_playwright() as p:
    b=await p.chromium.launch()
    for name,(t,pal) in TH.items():
      c=await b.new_context(viewport={'width':390,'height':844},device_scale_factor=2,is_mobile=True,has_touch=True)
      await c.add_init_script(f"try{{localStorage.setItem('wm-theme','{t}');localStorage.setItem('wm-pal','{pal}');localStorage.setItem('wm-pal-day','{pal}')}}catch(e){{}}")
      pg=await c.new_page(); await pg.goto('http://localhost:8978/profile-preview/d2pass.html'); await pg.wait_for_timeout(2500)
      el=await pg.query_selector('text=Appearance')
      if el:
        await el.scroll_into_view_if_needed(); await pg.wait_for_timeout(600)
      await pg.screenshot(path=f'settings_{name}.png'); print(name, bool(el)); await c.close()
    await b.close()
asyncio.run(m())
