import sys,time
from cdp import CDP
c=CDP(sys.argv[1]); k=int(sys.argv[2]); out=sys.argv[3]; h=int(sys.argv[4])
c.call('Emulation.setDeviceMetricsOverride',{'width':1568,'height':h,'deviceScaleFactor':1,'mobile':False})
time.sleep(2)
c.js(f'(()=>{{let m=[...document.querySelectorAll("div.rounded-lg.px-3.py-2")].filter(x=>x.innerText.startsWith("You\\n"));m[{k}].scrollIntoView({{block:"start"}})}})()')
time.sleep(1); c.shot(out); c.call('Emulation.clearDeviceMetricsOverride')
