Add configuration const #50
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the
src/content.jsfile 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
CONFIGobject 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
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
CONFIGobject and new helper functions, ensuring consistency and simplifying future updates. [1] [2] [3] [4]