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 fireBtn = (txt) => { for (const b of document.querySelectorAll('button')) if ((b.innerText||'').trim() === txt && b.offsetParent !== null) { const p = propsOf(b); if (p && typeof p.onClick === 'function') { p.onClick({target:b,currentTarget:b,stopPropagation(){},preventDefault(){},nativeEvent:{},button:0,detail:1}); return 'react'; } b.click(); return 'native'; } return null; }; const out = {}; out.apply = fireBtn('应用修改'); await sleep(4000); // 可能弹确认 out.btnsAfter = [...document.querySelectorAll('button')].filter(b=>b.offsetParent!==null).map(b=>(b.innerText||'').trim()).filter(t=>t).slice(0,30); const u13 = []; for (const c of await eda.pcb_PrimitiveComponent.getAll()) { if ((c.designator || '') !== 'U13') continue; for (const p of await eda.pcb_PrimitiveComponent.getAllPinsByPrimitiveId(c.primitiveId)) u13.push({n: String(p.padNumber), net: p.net || ''}); } out.u13 = u13.filter(p => ['2','5'].includes(p.n)); out.saved = await eda.pcb_Document.save(); return out;