Skip to content

Conversation

@koudaiii
Copy link
Owner

This pull request refactors the src/content.js file to improve maintainability, readability, and reusability by centralizing configuration values and extracting repeated logic into helper functions. The changes reduce code duplication and make it easier to update constants and selectors in the future.

Key improvements and refactoring:

Centralization of Configuration and Constants

  • Introduced a CONFIG object to hold constants for language, domain, URL patterns, selectors, style definitions, class names, and time constants, making the codebase easier to maintain and update.

Extraction of Helper Functions

  • Added helper functions (getLanguageFromUrl, getEnglishUrl, calculateTimeAgo, getTextColorClass, applyStyles) to encapsulate repeated logic, such as extracting the language from URLs, calculating time differences, determining theme classes, and applying styles. This reduces code repetition and improves readability.

Refactoring to Use Centralized Configurations and Helpers

  • Replaced hard-coded selectors, class names, and style assignments throughout the code with references to the CONFIG object and new helper functions, ensuring consistency and simplifying future updates. [1] [2] [3] [4]

@koudaiii koudaiii merged commit 08341a7 into main Nov 18, 2025
3 checks passed
@koudaiii koudaiii deleted the koudaiii/refactor branch November 18, 2025 09:03
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