const { chromium } = require('playwright'); (async () => { const b = await chromium.launch(); const p = await b.newPage({ viewport: { width: 1400, height: 900 } }); await p.goto('http://127.0.0.1:8794/', { waitUntil: 'load' }); await p.waitForTimeout(2500); await p.click('button:has-text("新建画布")').catch(() => {}); await p.waitForTimeout(2000); const buttons = await p.evaluate(() => Array.prototype.map.call(document.querySelectorAll('.iwb-dock-btn, .iwb-dock-head button'), (b) => ({ cls: b.className, tip: b.getAttribute('data-tip'), label: b.getAttribute('aria-label'), text: (b.textContent || '').trim().slice(0, 8) }))); console.log('dock buttons:', JSON.stringify(buttons).slice(0, 600)); const target = buttons.find((x) => (x.tip || x.label || x.text || '').indexOf('提示词') >= 0); console.log('target:', JSON.stringify(target)); if (target) { await p.click('.iwb-dock-btn[data-tip="' + target.tip + '"]').catch((e) => console.log('click2 err', e.message.slice(0, 50))); await p.waitForTimeout(2500); } const info = await p.evaluate(() => { const styles = Array.prototype.map.call(document.querySelectorAll('head style'), (s) => ({ attr: s.getAttribute('data-plugin') || '', len: s.textContent.length })); const body = document.querySelector('.iwb-dock-body'); const card = document.querySelector('.iwb-lib-card, .iwb-prompt-item, .iwb-plugin-panel *'); return { pluginStyleNodes: styles.filter((s) => s.attr), bodyH: body ? Math.round(body.getBoundingClientRect().height) : null, bodyCls: body ? String(body.className) : null, firstChildCls: body && body.firstElementChild ? String(body.firstElementChild.className).slice(0, 60) : null, cardW: card ? Math.round(card.getBoundingClientRect().width) : null, }; }); console.log(JSON.stringify(info, null, 1)); await p.screenshot({ path: '/tmp/panel2.png' }); await b.close(); })().catch((e) => { console.error('ERR', e.message); process.exit(1) });