// 抓那个拦截弹窗的完整文案 const pw = require('playwright-core'); (async () => { const b = await pw.chromium.connectOverCDP('http://127.0.0.1:9223'); const p = b.contexts()[0].pages().find(x => /recommend/.test(x.url())); // 先关掉可能开着的,重新触发一次 await p.evaluate(() => { document.querySelectorAll('.km-modal__close, .km-modal button').forEach(b => { try { b.click(); } catch { } }); }).catch(() => { }); await new Promise(r => setTimeout(r, 1500)); // 点击卡片 await p.evaluate(() => { document.querySelector('.recommend-item .resume-item__content, .recommend-item')?.click(); }).catch(() => { }); await new Promise(r => setTimeout(r, 3500)); const r = await p.evaluate(() => { const m = document.querySelector('.km-modal:not([class*=hidden]), .km-modal'); const all = [...document.querySelectorAll('.km-modal')]; return { count: all.length, texts: all.map(x => (x.innerText || '(空)').replace(/\n+/g, ' | ').slice(0, 150)), visible: all.map(x => x.offsetParent !== null), }; }).catch(e => ({ err: String(e).slice(0, 60) })); console.log(JSON.stringify(r, null, 1)); process.exit(0); })().catch(e => { console.log('ERR:', String(e).slice(0, 100)); process.exit(1); });