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 reqs=[]; c.on(m=>{ if(m.method==='Network.requestWillBeSent'){const r=m.params.request; if(/shein/i.test(r.url)&&/\.json/.test(r.url)&&r.method==='POST') reqs.push(r.url.replace('https://www.dianxiaomi.com','')); }}); await c.send('Network.enable').catch(()=>{}); const f = await c.evalJS(`(()=>{const m=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).pop(); if(!m)return'no-modal'; const ins=[...m.querySelectorAll('input')].filter(i=>i.offsetParent!==null&&i.placeholder==='请输入'); const vals=['10','18','3','2','18','5']; let n=0; ins.forEach((el,i)=>{ if(i>=vals.length)return; el.focus(); Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,'value').set.call(el, vals[i]); el.dispatchEvent(new Event('input',{bubbles:true})); el.dispatchEvent(new Event('change',{bubbles:true})); el.dispatchEvent(new Event('blur',{bubbles:true})); n++; }); return 'filled:'+n+'/'+ins.length+' vals='+ins.map(i=>i.value).join(',');})()`); console.log('填:', f); await wait(1500); await c.evalJS(`(()=>{const m=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null).pop(); if(!m)return 0; const b=[...m.querySelectorAll('button')].find(x=>/^\\s*确定\\s*$/.test(x.innerText||'')); if(b) for(const ev of ['mousedown','mouseup','click']) b.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window})); return 1;})()`); await wait(5000); const st = await c.evalJS(`(()=>{const p=document.querySelector('#app').__vue_app__.config.globalProperties.$pinia; const a=p._s.get('sheinSkuAttrStore').$state.formState; const openM=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null&&/编辑尺码表/.test(e.innerText||'')).length; return JSON.stringify({sizeTableInfo:String(JSON.stringify(a.sizeTableInfo)).slice(0,240), modalOpen:openM});})()`); console.log('尺码表:', String(st).slice(0,340)); await c.evalJS(`window.scrollTo(0,0)`); await wait(600); await c.evalJS(`(()=>{const x=[...document.querySelectorAll('button')].filter(e=>e.offsetParent!==null).find(e=>/^\\s*保存\\s*$/.test((e.innerText||'').trim())); if(!x)return 0; for(const ev of ['mousedown','mouseup','click']) x.dispatchEvent(new MouseEvent(ev,{bubbles:true,cancelable:true,view:window})); return 1;})()`); await wait(14000); await c.evalJS(`(()=>{const ms=[...document.querySelectorAll('.ant-modal')].filter(e=>e.offsetParent!==null); for(const m of ms){const b=[...m.querySelectorAll('button')].find(x=>/确定|确认|继续编辑/.test(x.innerText||'')); if(b)b.click();} return 1;})()`); await wait(4000); console.log('POST:', JSON.stringify([...new Set(reqs)].slice(0,4))); const t = await c.evalJS(`(()=>[...document.querySelectorAll('.ant-message-notice,.ant-notification-notice,.ant-modal')].filter(e=>e.offsetParent!==null).map(e=>(e.innerText||'').replace(/\\s+/g,' ').trim().slice(0,120)).filter(Boolean).slice(0,3))()`); console.log('提示:', String(t).slice(0,400)); process.exit(0);