refactor: simplify LinkedIn panel hiding#15
Conversation
… of DOM walking LinkedIn panel hiding now follows the same pattern as YouTube: query PANEL_SELECTORS directly instead of walking the DOM tree to find sibling columns. Also removes ~90 lines of dead code from linkedin-utils and simplifies isHomePage from 8 overlapping checks to a single regex. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughRefactors LinkedIn panel detection/hiding: utilities now return multiple panels via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/ts/websites/linkedin/linkedin-utils.ts (1)
27-35: Collect all matching elements to match the function contract.
document.querySelectoronly returns the first match per selector, butgetLinkedInPanels()is documented/typed as returning all panel elements. UsingquerySelectorAll+ dedupe is safer.♻️ Proposed refactor
/** Returns all panel elements matching PANEL_SELECTORS. */ function getLinkedInPanels(): HTMLElement[] { - const panels: HTMLElement[] = [] + const panels = new Set<HTMLElement>() for (const selector of PANEL_SELECTORS) { - const el = document.querySelector(selector) as HTMLElement | null - if (el) panels.push(el) + document.querySelectorAll<HTMLElement>(selector).forEach((el) => { + panels.add(el) + }) } - return panels + return Array.from(panels) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/ts/websites/linkedin/linkedin-utils.ts` around lines 27 - 35, getLinkedInPanels currently uses document.querySelector which returns only the first match for each selector but the function is typed/documented to return all matching panels; change implementation of getLinkedInPanels to use document.querySelectorAll for each selector, convert each NodeList to an array, push all matches into a single collection and dedupe (e.g., via a Set or filtering by identity) before returning so the result is an array of unique HTMLElement instances; keep references to PANEL_SELECTORS and the function name getLinkedInPanels to locate and update the code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/ts/websites/linkedin/linkedin-controller.ts`:
- Around line 101-104: The callback passed to forEach in hidePanels is using an
expression-bodied arrow which triggers Biome's useIterableCallbackReturn rule;
change the callback to a block-bodied form so it does not implicitly return a
value—for example, in LinkedInController.hidePanels(), replace
LinkedInUtils.getLinkedInPanels().forEach((panel) => this.hideElement(panel))
with a block-bodied callback that calls this.hideElement(panel) inside braces
(no return), referencing LinkedInUtils.getLinkedInPanels, hidePanels, and
hideElement to locate the change.
---
Nitpick comments:
In `@src/ts/websites/linkedin/linkedin-utils.ts`:
- Around line 27-35: getLinkedInPanels currently uses document.querySelector
which returns only the first match for each selector but the function is
typed/documented to return all matching panels; change implementation of
getLinkedInPanels to use document.querySelectorAll for each selector, convert
each NodeList to an array, push all matches into a single collection and dedupe
(e.g., via a Set or filtering by identity) before returning so the result is an
array of unique HTMLElement instances; keep references to PANEL_SELECTORS and
the function name getLinkedInPanels to locate and update the code.
… lint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
PANEL_SELECTORS, matching the same pattern YouTube uses for all its regionslinkedin-utils.ts(11 unused functions/constants from an older implementation)isHomePagefrom 8 overlapping string/regex checks to a single regexTest plan
npm test)selector-contract.test.ts)🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Bug Fixes