const puppeteer = require('puppeteer') const dotenv = require('dotenv') dotenv.config() async function run(ws, url) { console.log('connecting to', ws) const browser = await puppeteer.connect({ browserWSEndpoint: ws, defaultViewport: { width: 1400, height: 900 } }) const page = await browser.newPage() page.on('console', msg => console.log('PAGE LOG:', msg.text())) await page.goto(url, { waitUntil: 'networkidle2', timeout: 30000 }) await page.waitForTimeout(1500) const results = await page.evaluate(() => { function normalize(s){ return (s||'').replace(/\s+/g,' ').trim() } const nodes = Array.from(document.querySelectorAll('button,a,div[role="button"],input[type="button"]')) return nodes.slice(0,100).map(n => ({ tag: n.tagName, text: normalize(n.textContent||n.innerText||''), classes: n.className, role: n.getAttribute('role') || null, visible: (()=>{ const r=n.getBoundingClientRect(); return !!(r.width && r.height) })() })) }) console.log('Found elements count:', results.length) for (const r of results) console.log(JSON.stringify(r)) await browser.close() } const WS = process.env.BROWSERLESS_WS || process.argv[2] const URL = process.env.VITE_BROADCASTPANEL_URL || process.argv[3] || 'https://avanzacast-broadcastpanel.bfzqqk.easypanel.host' if (!WS) { console.error('Need ws endpoint'); process.exit(2) } run(WS, URL).catch(e => { console.error(e && e.stack ? e.stack : e); process.exit(3) })