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 p=propsOf(t); if(p&&typeof p.onClick==='function'){p.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; }; const find = (sub) => { const r=[]; for (const el of document.querySelectorAll('*')) { const t=(el.textContent||'').trim(); if (el.children.length===0 && t.includes(sub)) r.push(el); } return r; }; await eda.dmt_EditorControl.openDocument('7e9415a16a909c51'); await sleep(1200); const out = {}; fire(leaf('工具')); await sleep(900); const hits = find('运行命令'); out.hits = hits.map(e => ({txt: (e.textContent||'').trim(), tag: e.tagName, vis: e.offsetParent !== null})); if (!hits.length) { // 把当前浮层里所有可见叶子列出来 out.visibleLeaves = [...document.querySelectorAll('*')].filter(e => e.children.length===0 && e.offsetParent !== null && (e.textContent||'').trim().length>0 && (e.textContent||'').trim().length<26).map(e=>(e.textContent||'').trim()).slice(0, 300); return out; } out.fired = fire(hits[hits.length-1]); await sleep(1800); const inputs = [...document.querySelectorAll('input')].filter(i => i.offsetParent !== null); out.inputs = inputs.map(i => ({ph: i.placeholder, val: i.value})); out.visible = [...document.querySelectorAll('*')].filter(e => e.children.length===0 && e.offsetParent !== null && (e.textContent||'').trim().length>0 && (e.textContent||'').trim().length<40).map(e=>(e.textContent||'').trim()).slice(0, 200); return out;