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:8793/', { waitUntil: 'load' }); await p.waitForTimeout(2500); await p.click('button:has-text("新建画布")').catch(() => {}); await p.waitForTimeout(2000); // 打开左侧停靠栏里的「提示词库」面板 await p.click('.iwb-dock-btn[data-tip="提示词库"], .iwb-dock-btn[data-tip="风格库"], .iwb-dock-btn[data-tip="浏览器"]').catch((e) => console.log('click err', e.message.slice(0, 60))); 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') || s.id || '', len: s.textContent.length })); const panel = document.querySelector('.iwb-plugin-panel, .iwb-dock.right .iwb-dock-body, .iwb-dock-body'); const inner = document.querySelector('.iwb-promptlib, .iwb-plugin-panel-root, .iwb-dock-panel'); return { pluginStyleNodes: styles.filter((s) => s.attr).slice(0, 6), totalStyles: styles.length, panelCls: panel ? String(panel.className) : null, panelW: panel ? Math.round(panel.getBoundingClientRect().width) : null, innerTag: inner ? inner.tagName + '.' + String(inner.className).slice(0, 40) : null, dockRightW: (() => { const d = document.querySelector('.iwb-dock.right'); return d ? Math.round(d.getBoundingClientRect().width) : null })(), bootStyleLeft: !!document.getElementById('iwb-boot-static'), }; }); console.log(JSON.stringify(info, null, 1)); await p.screenshot({ path: '/tmp/plugin-panel.png' }); await b.close(); })().catch((e) => { console.error('ERR', e.message); process.exit(1) });