// @ts-nocheck // 诊断:点页签后输出祖先链几何,定位额外间距来源 const TAB = Number(process.argv[2] || 2) const TARGET = process.argv[3] || '.project-files__list' const js = `(async function(){ const tabs = document.querySelectorAll(".project-detail__tab"); if (${TAB} > 0 && tabs[${TAB} - 1]) { tabs[${TAB} - 1].click(); await new Promise(r => setTimeout(r, 900)); } let el = document.querySelector(${JSON.stringify(TARGET)}); const chain = []; while (el && chain.length < 6) { const r = el.getBoundingClientRect(); const cs = getComputedStyle(el); chain.push({ cls: (el.className || '').toString().slice(0, 40), y: +r.y.toFixed(1), h: +r.height.toFixed(1), mt: cs.marginTop, pt: cs.paddingTop, pb: cs.paddingBottom, gap: cs.gap, rowGap: cs.rowGap }); el = el.parentElement; } return JSON.stringify(chain, null, 0); })()` console.log(js)