// Inject the Beat Pocket bundle manually via addInitScript and capture errors const { chromium } = require('/usr/lib/node_modules/@playwright/test'); const fs = require('fs'); const BUNDLE = fs.readFileSync('/root/beat-pocket/extension/dist/content/index.js', 'utf8'); (async () => { const userDataDir = '/tmp/bb-inject-' + Date.now(); const context = await chromium.launchPersistentContext(userDataDir, { headless: true, channel: 'chromium', args: ['--disable-dev-shm-usage', '--no-sandbox'], // NO extension loading viewport: { width: 414, height: 896 }, }); const page = context.pages()[0] || await context.newPage(); page.on('console', (m) => console.log(`[page:${m.type()}]`, m.text().slice(0, 300))); page.on('pageerror', (e) => console.log('[page:error]', String(e).slice(0, 500))); // Inject the bundle as an init script — runs before the page's own JS // This bypasses the extension loader and lets us see if the bundle itself errors await page.addInitScript({ content: BUNDLE, }); await page.goto('https://beat-battle.net/', { waitUntil: 'domcontentloaded', timeout: 30000 }); await page.waitForTimeout(5000); const result = await page.evaluate(() => { const allBbp = document.querySelectorAll('[class*="bbp-"], #bbp-overlay-host, [data-bbp]'); return { bbpMarkerCount: allBbp.length, sampleClasses: Array.from(allBbp).slice(0, 8).map(el => el.className).join(' | '), htmlClass: document.documentElement.className, bodyClass: document.body?.className, }; }); console.log('[inject:result]', result); await context.close(); })().catch((e) => { console.error('FAIL:', e); process.exit(1); });