# 試算の「店を選ぶ」カードの見せ方を、CSS を足して描き分け、画面写真を撮る(大型店を選んだ状態) # 使い方: python3 store_card_trials.py import asyncio, sys from pathlib import Path from playwright.async_api import async_playwright src=Path(sys.argv[1]).resolve().as_uri()+'?embed=1' SEL='''.stores input:checked + label{background:#f5f5f0!important;border-color:#f5f5f0!important;box-shadow:none;color:#111!important} .stores input:checked + label span{color:#444!important}.stores input:checked + label em{color:#777!important}''' V={ '今':'', '① 反転':'''.stores input:checked + label{background:var(--ink)!important;border-color:var(--ink)!important;box-shadow:none;color:#fff} .stores input:checked + label span{color:rgba(255,255,255,.85)}.stores input:checked + label em{color:rgba(255,255,255,.6)}''', '② 色を足す':'''.stores input:checked + label{background:#fff3c4!important;border-color:#e0a800!important;box-shadow:inset 0 0 0 1px #e0a800} .stores input:checked + label b::before{content:"✓ ";color:#b07f00}''', '③ 反転+印':'''.stores input:checked + label{background:var(--ink)!important;border-color:var(--ink)!important;box-shadow:none;color:#fff} .stores input:checked + label span{color:rgba(255,255,255,.85)}.stores input:checked + label em{color:rgba(255,255,255,.6)} .stores input:checked + label b::after{content:"選択中";margin-left:8px;font-size:10px;font-weight:600;padding:1px 6px;border-radius:3px;background:#fff;color:var(--ink);vertical-align:2px}''', 'A 店を選ぶ欄だけ黒背景(選んだ店は白)':''' .stores{background:#111;padding:12px;border-radius:12px} html.embed .stores label{background:#2a2a2a!important;border-color:#2a2a2a!important;color:#f5f5f0!important} .stores label span{color:#d0d0cc!important}.stores label em{color:#9a9a96!important}'''+SEL, 'B ページ全体を黒背景(選んだものは白)':''' html:root{--bg:#111;--panel:#1d1d1d;--ink:#f5f5f0;--ink-2:#d0d0cc;--ink-3:#9a9a96;--soft:#2a2a2a} html.embed body{background:#111!important;color:#f5f5f0} html.embed .stores label,html.embed .controls,html.embed .kpi,html.embed .chart,html.embed .compare,html.embed details{background:#1d1d1d!important} html.embed .stores label{border-color:#1d1d1d!important} .seg input:checked + label,.chip.good,.modes input:checked + label,.seg .more.on,.chip-btn.on{color:#111!important}'''+SEL, 'C 白背景のまま、選んでいない店を薄くする':''' .stores input:not(:checked) + label{opacity:.4} .stores input:checked + label{background:#fff!important;border:2px solid var(--ink)!important;box-shadow:0 4px 14px rgba(0,0,0,.12)}''', } async def main(): async with async_playwright() as p: b=await p.chromium.launch(); pg=await b.new_page(viewport={'width':1280,'height':1000}) for i,(k,css) in enumerate(V.items()): await pg.goto(src); await pg.wait_for_timeout(600) await pg.evaluate("()=>{document.querySelectorAll('.stores input')[2].click()}") if css: await pg.add_style_tag(content=css) await pg.wait_for_timeout(300) x,y,w,h=await pg.evaluate("()=>{const r=document.getElementById('stores').getBoundingClientRect();return [r.x,r.y,r.width,r.height]}") await pg.screenshot(path=f'store_{i}.png',clip={'x':0,'y':max(0,y-40),'width':1280,'height':h+300}) print(i,k) await b.close() asyncio.run(main())