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) { 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.confirm = fireBtn('确认'); await sleep(1500); const pd = await eda.pcb_PrimitivePoured.getAll(); out.poured = pd.map(x => ({net: x.net, layer: x.layer, keys: Object.keys(x).slice(0,14)})); out.saved = await eda.pcb_Document.save(); await sleep(1000); out.pouredAfterSave = (await eda.pcb_PrimitivePoured.getAll()).length; return out;