26 lines
1.4 KiB
JavaScript
26 lines
1.4 KiB
JavaScript
// 终极诊断:拦截弹窗是canvas/图片渲染或iframe——查iframe和shadow DOM
|
|
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()));
|
|
const st = await p.evaluate(() => {
|
|
const m = document.querySelector('.km-modal--open, .km-modal:not([style*="display: none"])');
|
|
if (!m) return { noModal: true };
|
|
// 弹窗内部结构全景
|
|
const walk = (el, depth) => {
|
|
if (!el || depth > 3) return '';
|
|
let out = `${'.'.repeat(depth)}<${el.tagName.toLowerCase()} class="${String(el.className).slice(0, 40)}" text="${(el.childNodes.length===1&&el.textContent||'').trim().slice(0,30)}">\n`;
|
|
if (el.tagName === 'IFRAME') out += `${'.'.repeat(depth+1)}IFRAME src=${el.src?.slice(0, 80)}\n`;
|
|
for (const c of el.children || []) out += walk(c, depth + 1);
|
|
return out;
|
|
};
|
|
const iframes = [...document.querySelectorAll('iframe')].map(f => ({ src: f.src?.slice(0, 70), visible: f.offsetParent !== null }));
|
|
return {
|
|
modalHTML: m.outerHTML.slice(0, 600),
|
|
iframes,
|
|
};
|
|
}).catch(e => ({ err: String(e).slice(0, 80) }));
|
|
console.log(JSON.stringify(st, null, 1).slice(0, 1200));
|
|
process.exit(0);
|
|
})().catch(e => { console.log('ERR:', String(e).slice(0, 100)); process.exit(1); });
|