Skip to content

Refactor: Modular scanner + shared parsing utils and modular popup UI#10

Merged
OstinUA merged 1 commit intomainfrom
codex/task-title
Apr 20, 2026
Merged

Refactor: Modular scanner + shared parsing utils and modular popup UI#10
OstinUA merged 1 commit intomainfrom
codex/task-title

Conversation

@OstinUA
Copy link
Copy Markdown
Owner

@OstinUA OstinUA commented Apr 20, 2026

Motivation

  • Remove monolithic extraction code and improve separation of concerns between parsing, scanning, and popup UI to make the extension easier to maintain and extend.
  • Reduce runtime fragility by introducing deterministic timeouts, fetch cancellation, and safer lifecycle handling for content-script injections.
  • Centralize normalization, de-obfuscation and priority sorting logic to ensure consistent results across scanner and popup renderer.

Description

  • Split core parsing/sanitization/sorting into a reusable module at shared/email-utils.js and implemented a dedicated scanning engine at content/scanner.js.
  • Rewrote content.js as a lightweight orchestrator that prevents duplicate concurrent runs, listens for stopScanning messages, and provides fail-safe empty-result reporting.
  • Modularized the popup into presentation and state modules (popup/render.js, popup/state.js) and updated popup.js and popup.html to use them for deterministic loading, empty-state and clipboard behaviors.
  • Improved styles in styles.css, added AbortController-based fetch timeouts, bounded runtime logic, contact-page fallback scanning, and centralized result sorting via sortByBusinessPriority for consistent UI ordering.

Testing

  • Manifest JSON validation with python -m json.tool manifest.json completed successfully.
  • Static syntax checks with node --check were run for shared/email-utils.js, content/scanner.js, content.js, popup/render.js, popup/state.js, and popup.js, and all returned OK.
  • Manual smoke expectations exercised through the popup flow were covered by adding deterministic loading/empty states and fail-safe messaging; automated runtime checks listed above passed.

Codex Task

Summary by CodeRabbit

Release Notes

  • New Features

    • Improved email detection with support for additional obfuscation formats
    • Enhanced scanning with timeout and cancellation controls
    • Added status indicators in the popup UI for better feedback
  • Bug Fixes

    • Better email extraction from various page content sources
    • Improved handling of Cloudflare-protected emails
  • Style

    • Updated button styling and layout with improved visual hierarchy
    • New status display indicators for clearer user feedback
    • Optimized popup layout for better readability

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request refactors the email scanner extension by extracting scanning logic into modular components. A new EmailScannerFactory handles two-phase document scanning with fallback contact-page fetching, supported by EmailParserUtils utilities. The popup architecture shifts to state management via PopupState and rendering via PopupRender. The content script becomes a thin wrapper delegating to the factory, with updated CSS classes and HTML markup supporting the new component structure.

Changes

Cohort / File(s) Summary
Core Scanner Module
content/scanner.js
New factory-based scanner implementation with configurable limits, two-phase scanning (document + contact-page fallback), cooperative cancellation via requestStop(), and messaging to relay results.
Shared Email Utilities
shared/email-utils.js
New module providing email extraction, normalization, obfuscation detection, Cloudflare decoding, HTML entity handling, and business-priority sorting.
Popup State & Rendering
popup/state.js, popup/render.js
Two new modules: PopupState manages email list, loading state, and active tab ID; PopupRender provides status and email-list rendering with copy/mailto buttons.
Content Script Refactoring
content.js
Replaced self-contained scanning logic with thin wrapper that creates scanner via factory, registers stop-message listener, enforces hard timeout (~21s), and delegates execution.
Popup Script Refactoring
popup.js
Refactored to use shared state/render APIs, updated script injection to load utils and scanner before content.js, simplified message handling, and adopted async clipboard copying with fallback.
Popup Markup & Styling
popup.html, styles.css
Updated HTML to load new script modules and normalize attributes; added CSS classes (.status, .status-loading, .status-empty, .btn-group, .btn-primary) and increased max-height for scrollable list area.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A burrow of modules, so neat and so bright,
Factories and utils now split up just right!
State blooms in the popup, renderers align,
Email extraction refined, a refactor divine~ 🌿✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes motivation, a clear breakdown of changes across multiple files, and testing verification. However, it does not follow the provided template structure with sections like 'Related Issue(s)', 'Type of Change', 'Testing Performed', and 'Checklist'. Reformat the description to match the template: add 'Related Issue(s)' section, use the provided 'Type of Change' checkboxes (mark 'Refactoring / Technical Debt'), follow 'Testing Performed' format, and complete the 'Checklist' section.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: a refactoring that modularizes the scanner logic and parsing utilities into reusable modules while restructuring the popup UI into separate presentation and state modules.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/task-title

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@OstinUA OstinUA merged commit e698998 into main Apr 20, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant