Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions userscript/source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/return *[A-Za-z.-9]+ *\( *[0-9a-fx *+-]+ *, *[A-Za-z.-9]+ *, *[A-Za-z.-9]+ *, *[0-9a-fx *+-]+ *,[A-Za-z.-9]+ *, *[A-Za-z.-9]+ * *\) *; *}/
]]

function PowerLinkElementFromArg(Arg: unknown): HTMLElement | null {

Check warning on line 32 in userscript/source/index.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

'PowerLinkElementFromArg' is defined but never used

Check warning on line 32 in userscript/source/index.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

'PowerLinkElementFromArg' is defined but never used
if (typeof Arg !== 'object' || Arg === null) return null

const Visited = new Set<object>()
Expand Down Expand Up @@ -102,6 +102,9 @@
const MaxRatio = 0.75
const EpsilonRatio = 0.04

function ParseCssFloat(Value: string): number {
return Number.parseFloat(Value) || 0
}

let CommentContainer: Element = null
let InHook = false
Expand All @@ -119,8 +122,8 @@
if (PL2Element !== null && [...PL2Element.querySelectorAll('*')].filter(Child => {
if (!(Child instanceof HTMLElement)) return false
let PL2TitleHeight = Child.getClientRects()[0]?.height ?? 0
let PL2TitleMarginBottom = Math.max(Number(getComputedStyle(Child).getPropertyValue('padding-bottom').replaceAll(/px/g, '')),
Number(getComputedStyle(Child).getPropertyValue('margin-bottom').replaceAll(/px/g, '')))
let PL2TitleMarginBottom = Math.max(ParseCssFloat(getComputedStyle(Child).getPropertyValue('padding-bottom')),
ParseCssFloat(getComputedStyle(Child).getPropertyValue('margin-bottom')))
return PL2TitleHeight > 0 && PL2TitleMarginBottom >= PL2TitleHeight * (MinRatio - EpsilonRatio) && PL2TitleMarginBottom <= PL2TitleHeight * (MaxRatio + EpsilonRatio)
}).length >= 1) {
console.debug(`[${UserscriptName}]: Function.prototype.call called for PowerLink Skeleton:`, ThisArg)
Expand Down Expand Up @@ -148,8 +151,8 @@
[...PL2Element.querySelectorAll('*')].filter(Child => {
if (!(Child instanceof HTMLElement)) return false
let PL2TitleHeight = Child.getClientRects()[0]?.height ?? 0
let PL2TitleMarginBottom = Math.max(Number(getComputedStyle(Child).getPropertyValue('padding-bottom').replaceAll(/px/g, '')),
Number(getComputedStyle(Child).getPropertyValue('margin-bottom').replaceAll(/px/g, '')))
let PL2TitleMarginBottom = Math.max(ParseCssFloat(getComputedStyle(Child).getPropertyValue('padding-bottom')),
ParseCssFloat(getComputedStyle(Child).getPropertyValue('margin-bottom')))
return PL2TitleHeight > 0 && PL2TitleMarginBottom >= PL2TitleHeight * (MinRatio - EpsilonRatio) && PL2TitleMarginBottom <= PL2TitleHeight * (MaxRatio + EpsilonRatio)
}).length >= 1
) {
Expand Down Expand Up @@ -185,14 +188,14 @@
setTimeout(() => {
let ContainerElements = new Set([CommentContainer])
ContainerElements = new Set([...ContainerElements, ...[...ContainerElements].flatMap(Container => [...Container.querySelectorAll('*')])])
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-bottom-width').replaceAll(/px/g, '')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-left-width').replaceAll(/px/g, '')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-right-width').replaceAll(/px/g, '')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-top-width').replaceAll(/px/g, '')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => ParseCssFloat(getComputedStyle(Container).getPropertyValue('border-bottom-width')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => ParseCssFloat(getComputedStyle(Container).getPropertyValue('border-left-width')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => ParseCssFloat(getComputedStyle(Container).getPropertyValue('border-right-width')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => ParseCssFloat(getComputedStyle(Container).getPropertyValue('border-top-width')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => [...Container.querySelectorAll('*')].some(Child => {
if (!(Child instanceof HTMLElement)) return false
let PL2TitleHeight = Child.getClientRects()[0]?.height ?? 0
let PL2TitleMarginBottom = Number(getComputedStyle(Child).getPropertyValue('margin-bottom').replaceAll(/px/g, ''))
let PL2TitleMarginBottom = ParseCssFloat(getComputedStyle(Child).getPropertyValue('margin-bottom'))
if (PL2TitleHeight === 0) return false
return PL2TitleMarginBottom >= PL2TitleHeight * 0.65 && PL2TitleMarginBottom <= PL2TitleHeight * 1.25
})))
Expand All @@ -208,15 +211,15 @@
let ContainerElements = new Set([...BrowserWindow.document.querySelectorAll('div[class] div[class] div[class] ~ div[class]')])
ContainerElements = new Set([...ContainerElements].filter(Container => Container instanceof HTMLElement))
ContainerElements = new Set([...ContainerElements].filter(Container =>
Number(getComputedStyle(Container).getPropertyValue('margin-bottom').replaceAll(/px$/g, '')) > 15 ||
Number(getComputedStyle(Container).getPropertyValue('padding-top').replaceAll(/px$/g, '')) > 20
ParseCssFloat(getComputedStyle(Container).getPropertyValue('margin-bottom')) > 15 ||
ParseCssFloat(getComputedStyle(Container).getPropertyValue('padding-top')) > 20
))
ContainerElements = new Set([...ContainerElements].filter(Container => Container instanceof HTMLElement && Container.innerText.trim().length === 0))
ContainerElements = new Set([...ContainerElements].filter(Container => [...Container.querySelectorAll('*')].some(Child => Child instanceof HTMLElement &&
(Number(getComputedStyle(Child).getPropertyValue('padding-top').replaceAll(/px/g, '')) >= 5 &&
Number(getComputedStyle(Child).getPropertyValue('padding-bottom').replaceAll(/px/g, '')) >= 5 &&
Number(getComputedStyle(Child).getPropertyValue('padding-left').replaceAll(/px/g, '')) >= 5 &&
Number(getComputedStyle(Child).getPropertyValue('padding-right').replaceAll(/px/g, '')) >= 5)
(ParseCssFloat(getComputedStyle(Child).getPropertyValue('padding-top')) >= 5 &&
ParseCssFloat(getComputedStyle(Child).getPropertyValue('padding-bottom')) >= 5 &&
ParseCssFloat(getComputedStyle(Child).getPropertyValue('padding-left')) >= 5 &&
ParseCssFloat(getComputedStyle(Child).getPropertyValue('padding-right')) >= 5)
)))
console.debug(`[${UserscriptName}]: Removing PowerLink Skeleton Containers (PL2PlaceHolderMobile):`, ContainerElements)
ContainerElements.forEach(Container => {
Expand All @@ -229,16 +232,16 @@
let ContainerElements = new Set([...BrowserWindow.document.querySelectorAll('div[class] div[class] div[class] ~ div[class]')])
ContainerElements = new Set([...ContainerElements].filter(Container => Container instanceof HTMLElement))
ContainerElements = new Set([...ContainerElements].filter(Container => {
return Number(getComputedStyle(Container).getPropertyValue('padding-top').replaceAll(/px$/g, '')) > 10 ||
Number(getComputedStyle(Container).getPropertyValue('margin-top').replaceAll(/px$/g, '')) > 10
return ParseCssFloat(getComputedStyle(Container).getPropertyValue('padding-top')) > 10 ||
ParseCssFloat(getComputedStyle(Container).getPropertyValue('margin-top')) > 10
}))
ContainerElements = new Set([...ContainerElements, ...[...ContainerElements].flatMap(Container => [...Container.querySelectorAll('*:not(button)')])])
ContainerElements = new Set([...ContainerElements].filter(Container => Container instanceof HTMLElement && Container.innerText.trim().length === 0))
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-bottom-width').replaceAll(/px/g, '')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-left-width').replaceAll(/px/g, '')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-right-width').replaceAll(/px/g, '')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('border-top-width').replaceAll(/px/g, '')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => Number(getComputedStyle(Container).getPropertyValue('transition-duration').replaceAll(/s$/g, '')) >= 0.01))
ContainerElements = new Set([...ContainerElements].filter(Container => ParseCssFloat(getComputedStyle(Container).getPropertyValue('border-bottom-width')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => ParseCssFloat(getComputedStyle(Container).getPropertyValue('border-left-width')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => ParseCssFloat(getComputedStyle(Container).getPropertyValue('border-right-width')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => ParseCssFloat(getComputedStyle(Container).getPropertyValue('border-top-width')) >= 0.5))
ContainerElements = new Set([...ContainerElements].filter(Container => ParseCssFloat(getComputedStyle(Container).getPropertyValue('transition-duration')) >= 0.01))
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transition-duration is a time value and can be a comma-separated list (e.g. "0s, 0.2s"). ParseCssFloat(...) only parses the first numeric prefix and ignores units/list entries, which can lead to false positives/negatives for the >= 0.01 threshold. Consider a dedicated parser for transition durations that splits on commas, normalizes ms/s, and compares (e.g. max duration) against the threshold.

Copilot uses AI. Check for mistakes.
console.debug(`[${UserscriptName}]: Removing PowerLink Skeleton Containers (PL2PlaceHolder):`, ContainerElements)
ContainerElements.forEach(Container => {
Container.setAttribute('style', 'display: none !important;')
Expand Down
Loading