refactor: refactor margin and padding calculations to use ParseCssFloat#224
refactor: refactor margin and padding calculations to use ParseCssFloat#224piquark6046 merged 1 commit intomainfrom
ParseCssFloat#224Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors CSS numeric parsing in the userscript to centralize the conversion logic into a ParseCssFloat helper, simplifying margin/padding/border width checks used for detecting and removing PowerLink skeleton containers.
Changes:
- Introduces
ParseCssFloatto parse computed-style numeric values with a fallback to0. - Replaces repeated
replaceAll(/px/g, '')+Number(...)conversions withParseCssFloat(...)across multiple style-property checks. - Applies the same parsing helper to border-width and spacing heuristics used in PL2 container detection/removal.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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)) |
There was a problem hiding this comment.
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.
No description provided.