Skip to content

github-repo-size-view的fixPageHeader页面穿透 #292

@Gearace

Description

@Gearace

Expected Behavior

github-repo-size-view的fixPageHeader加了 position: fixed,没给 z-index,导致层叠顺序和普通内容一样,内容会“穿过”头部,让AI给加了段代码,另使用zen browser。

// 计算z-indxe
function getMaxZIndex() {
return [...document.querySelectorAll('*')]
.map(el => parseFloat(getComputedStyle(el).zIndex))
.filter(z => !isNaN(z))
.reduce((max, z) => Math.max(max, z), 0)
}

function fixPageHeader() {
const header = document.querySelector('.AppHeader, header[role="banner"]')
if (!header) { return }

// 获取z-index
const baseZIndex = getMaxZIndex()
const headerZIndex = baseZIndex + 10 // 比当前最高层再高一点

const css = document.createElement('style')
css.id = 'fixed-header-style'
css.innerHTML = `

.AppHeader, header[role="banner"] {
position: fixed !important;
top: 0 !important;
left: 0 !important;
width: 100% !important;
// 确保头部在内容之上
z-index: ${headerZIndex} !important;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
body {
padding-top: ${header.offsetHeight}px !important;
}
`
document.head.appendChild(css)
}

Actual Behavior

如上

Steps to Reproduce

如上

Script Manager or Browser

Violentmonkey

Script Manager or Browser Version

No response

Browser and Engine Version

zen browser 1.19.13b x64

Operating System

win11 ltsc x64

Script Version

Last Modified: 2026/03/16,Monday 15:09:30

Additional Information

No response

I confirm the bug really exists

  • This bug really exists, please fix it as soon as possible

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions