const { chromium } = require('playwright'); (async () => { const b = await chromium.launch(); const p = await b.newPage({ viewport: { width: 1400, height: 900 } }); const errs = []; p.on('console', (m) => { if (m.type() === 'error') errs.push(m.text().slice(0, 100)) }); await p.goto('http://127.0.0.1:8796/', { waitUntil: 'load' }); await p.waitForTimeout(2500); await p.click('button:has-text("新建画布")').catch(() => {}); await p.waitForTimeout(2500); const dock = await p.evaluate(() => Array.prototype.map.call(document.querySelectorAll('.iwb-dock-btn'), (b) => ({ label: b.getAttribute('aria-label'), cls: b.className }))); console.log('dock:', JSON.stringify(dock)); const btn = await p.$('.iwb-dock-btn[aria-label="提示词库"]'); if (btn) { await btn.click({ force: true }).catch((e) => console.log('click 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) => ({ p: s.getAttribute('data-plugin') || '', len: s.textContent.length })); const body = document.querySelector('.iwb-dock.right .iwb-dock-body') || document.querySelector('.iwb-dock-body'); return { pluginStyles: styles.filter((s) => s.p), bodyCls: body ? String(body.className) : null, bodyW: body ? Math.round(body.getBoundingClientRect().width) : null, firstChild: body && body.firstElementChild ? String(body.firstElementChild.className).slice(0, 50) : null, dockRightW: (() => { const d = document.querySelector('.iwb-dock.right'); return d ? Math.round(d.getBoundingClientRect().width) : null })(), }; }); console.log(JSON.stringify(info, null, 1)); console.log('errs:', JSON.stringify(errs.slice(0, 4))); await p.screenshot({ path: '/tmp/panel-head.png' }); await b.close(); })().catch((e) => { console.error('ERR', e.message); process.exit(1) });