import { attach } from '/tmp/cdp3.mjs'; const wait = ms => new Promise(z => setTimeout(z, ms)); const c = await attach('/web/sheinProduct/add') || await attach('dianxiaomi.com'); // 打开尺码表弹窗 const pos = JSON.parse(String(await c.evalJS(`(()=>{const it=[...document.querySelectorAll('.ant-form-item')].filter(e=>e.offsetParent!==null) .find(x=>{const l=x.querySelector('label'); return l&&/尺码表/.test(l.innerText||'');}); if(!it)return'[]'; const el=it.querySelector('.link')||it.querySelector('a,span'); if(!el)return'[]'; el.scrollIntoView({block:'center'}); const r=el.getBoundingClientRect(); return JSON.stringify([Math.round(r.x+r.width/2),Math.round(r.y+r.height/2)]);})()`))); if(pos.length){ for(const t of ['mousePressed','mouseReleased']) await c.send('Input.dispatchMouseEvent',{type:t,x:pos[0],y:pos[1],button:'left',clickCount:1}); } await wait(6000); const o = await c.evalJS(`(()=>{const m=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).pop(); if(!m)return'no-modal'; const rows=[...m.querySelectorAll('tr')].slice(0,10).map(tr=>[...tr.querySelectorAll('td,th')].map(td=>{ const i=td.querySelector('input'); return i?('IN:'+(i.placeholder||i.value||'')):(td.innerText||'').replace(/\\s+/g,' ').trim().slice(0,18);})); return JSON.stringify({title:(m.querySelector('.ant-modal-title')||{}).innerText||'', rows, btns:[...m.querySelectorAll('button')].map(b=>(b.innerText||'').trim()).slice(0,10)},null,1);})()`); console.log(String(o).slice(0,1500)); process.exit(0);