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 o = 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'nf'; return JSON.stringify({txt:(it.innerText||'').replace(/\\s+/g,' ').slice(0,120), html:it.innerHTML.slice(0,600)});})()`); console.log('分类控件:', String(o).slice(0,900)); 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('.ant-select-selector')||it.querySelector('input'); 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 type of ['mousePressed','mouseReleased']) await c.send('Input.dispatchMouseEvent',{type,x:pos[0],y:pos[1],button:'left',clickCount:1}); await wait(4000); } const o2 = await c.evalJS(`(()=>{ const ms=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).map(m=>({t:(m.querySelector('.ant-modal-title')||{}).innerText||'', inputs:[...m.querySelectorAll('input')].map(i=>i.placeholder||i.type).slice(0,5), btns:[...m.querySelectorAll('button')].map(b=>(b.innerText||'').trim()).slice(0,6), txt:(m.innerText||'').replace(/\\s+/g,' ').slice(0,300)})); const dd=[...document.querySelectorAll('.ant-select-dropdown')].filter(e=>e.offsetParent!==null).map(d=>(d.innerText||'').replace(/\\s+/g,' ').slice(0,260)); return JSON.stringify({modals:ms, dropdowns:dd},null,1);})()`); console.log(String(o2).slice(0,1400)); process.exit(0);