const sleep = ms => new Promise(r=>setTimeout(r,ms)); const propsOf = el => { for (const k of Object.keys(el)) if (k.startsWith('__reactProps$')) return el[k]; return null; }; const fire = (el) => { let t = el; for (let i=0;i<8&&t;i++){const q=propsOf(t); if(q&&typeof q.onClick==='function'){q.onClick({target:t,currentTarget:t,stopPropagation(){},preventDefault(){},nativeEvent:{},button:0,detail:1});return true;} t=t.parentElement;} return false; }; const leaf = (txt) => { for (const el of document.querySelectorAll('*')) if (el.children.length===0 && (el.textContent||'').trim()===txt) return el; return null; }; fire(leaf('布线')); await sleep(700); fire(leaf('自动布线...')); await sleep(2200); let b=null; for (const x of document.querySelectorAll('button')) if((x.innerText||'').trim()==='运行' && x.offsetParent!==null) b=x; if(!b) return {err:'no run btn'}; fire(b); await sleep(8000); return {log: window.__arLog.slice(0,40), l:(await eda.pcb_PrimitiveLine.getAll()).length};