Skip to content

refactor: refactor margin and padding calculations to use ParseCssFloat#224

Merged
piquark6046 merged 1 commit intomainfrom
fix/avoid-replaceAll
Mar 20, 2026
Merged

refactor: refactor margin and padding calculations to use ParseCssFloat#224
piquark6046 merged 1 commit intomainfrom
fix/avoid-replaceAll

Conversation

@piquark6046
Copy link
Member

No description provided.

@piquark6046 piquark6046 marked this pull request as ready for review March 20, 2026 06:04
Copilot AI review requested due to automatic review settings March 20, 2026 06:04
@piquark6046 piquark6046 merged commit 07dd8ec into main Mar 20, 2026
9 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ParseCssFloat to parse computed-style numeric values with a fallback to 0.
  • Replaces repeated replaceAll(/px/g, '') + Number(...) conversions with ParseCssFloat(...) 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))
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants