Skip to content

Commit 5c8021b

Browse files
committed
fix: exclude other HTMLElement by checking PowerLink title HTMLElement
1 parent 807094a commit 5c8021b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎userscript/source/index.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ export function RunNamuLinkUserscript(BrowserWindow: typeof window, UserscriptNa
7070
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-left-width').replaceAll(/px/g, '')) >= 0.5))
7171
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-right-width').replaceAll(/px/g, '')) >= 0.5))
7272
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-top-width').replaceAll(/px/g, '')) >= 0.5))
73+
ContainerElements = new Set([...ContainerElements].filter(Container => [...Container.querySelectorAll('*')].some(Child => {
74+
if (!(Child instanceof HTMLElement)) return false
75+
let PL2TitleHeight = Child.getClientRects()[0]?.height ?? 0
76+
let PL2TitleMarginBottom = Number(getComputedStyle(Child).getPropertyValue('margin-bottom').replaceAll(/px/g, ''))
77+
return PL2TitleMarginBottom >= PL2TitleHeight * 0.75 && PL2TitleMarginBottom <= PL2TitleHeight * 1.25
78+
})))
7379
console.debug(`[${UserscriptName}]: Removing PowerLink Skeleton Containers:`, ContainerElements)
7480
ContainerElements.forEach(Container => {
7581
Container.setAttribute('style', 'display: none !important;')

0 commit comments

Comments
 (0)