You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
2.2 KiB
50 lines
2.2 KiB
# -*- coding: utf-8 -*-
|
|
"""带恒等注入的深度诊断:console 全量 + 主容器隐藏点"""
|
|
import io, sys, time
|
|
from pathlib import Path
|
|
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
|
|
|
|
html_path = Path(r'e:\code\crm-backend-matt\.scratch\a7-parity\pages\a7-3-1_线索规则\a7-3-1_线索规则.html')
|
|
url = 'file:///' + str(html_path).replace('\\', '/')
|
|
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch()
|
|
ctx = browser.new_context(viewport={'width': 1600, 'height': 900})
|
|
ctx.add_init_script(
|
|
"window.lanhu_Axure_Mapping_Data = function(d){ return d; };")
|
|
page = ctx.new_page()
|
|
page.on('console', lambda m: print(f'[c.{m.type}] {m.text[:220]}'))
|
|
page.on('pageerror', lambda e: print(f'[pageerror] {str(e)[:300]}'))
|
|
page.on('requestfailed', lambda r: print(f'[reqfail] {r.url[:130]} {r.failure}'))
|
|
page.goto(url, wait_until='domcontentloaded', timeout=20000)
|
|
time.sleep(3)
|
|
page.evaluate("() => { try { window.dispatchEvent(new Event('load')); } catch(e){} }")
|
|
time.sleep(2)
|
|
info = page.evaluate("""() => {
|
|
const body = document.body;
|
|
const kids = [...body.children].slice(0, 12).map(el => {
|
|
const cs = getComputedStyle(el);
|
|
return {tag: el.tagName, id: el.id, cls: (el.className||'').toString().slice(0,40),
|
|
display: cs.display, vis: cs.visibility, h: cs.height,
|
|
inlineStyle: (el.getAttribute('style')||'').slice(0,120)};
|
|
});
|
|
const bcs = getComputedStyle(body);
|
|
return {bodyLen: body.innerHTML.length,
|
|
uDivs: document.querySelectorAll('[id^=u]').length,
|
|
bodyOverflow: bcs.overflow, bodyH: bcs.height, bodyVis: bcs.visibility,
|
|
scrollH: document.documentElement.scrollHeight,
|
|
kids};
|
|
}""")
|
|
print('=== DOM state ===')
|
|
for k, v in info.items():
|
|
if k == 'kids':
|
|
print('body children:')
|
|
for c in v:
|
|
print(' ', c)
|
|
else:
|
|
print(k, ':', v)
|
|
browser.close()
|
|
|