Releases: jls42/BabelFishAI
Release list
v1.1.19 - Firefox Support
🦊 Firefox Support
BabelFishAI est maintenant disponible sur Firefox ! Cette version ajoute la compatibilité complète avec Firefox tout en conservant le support Chrome.
Nouveautés
- Support Firefox : Extension compatible Firefox (Manifest V3)
- Build multi-navigateur : Script
./scripts/build.shpour générer les packages Chrome et Firefox - Architecture Firefox : Appels API via le background script (pattern recommandé pour les extensions Firefox)
Améliorations techniques
- Optimisation du proxy Firefox avec encodage Base64 pour les uploads audio
- Réduction de la complexité cyclomatique dans
focus-utils.js - Remplacement de
innerHTMLparDOMParserpour la sécurité - Icônes corrigées (dimensions carrées)
- Ajout de
data_collection_permissionsdans le manifest Firefox
Release v1.1.18 - Support Mistral AI (Voxtral)
🎉 Nouveau Provider : Mistral AI
- Transcription vocale avec Voxtral : nouveau modèle de transcription de Mistral AI
- Modèles chat Mistral : Small, Medium, Large et Codestral pour la traduction/reformulation
- Architecture multi-provider : nouveau système de registre des providers (providers.js)
- Sélection indépendante du provider pour transcription et traduction
🧹 Nettoyage de la dette technique
- Suppression des modules deprecated (api.js, translation.js, text-translation.js, languages.js)
- Réduction des fonctions sur-exposées (focus-utils.js, ui.js)
- Corrections pour les analyseurs de code statique (SonarCloud, Codacy, DeepSource)
1.1.17
This major refactoring improves the maintainability and readability of the code by breaking down the content.js file (>2000 lines) into specialized modules:
Creation of 9 new utility files:
- api-utils.js: Functions for interacting with APIs
- banner-utils.js: Banner display management
- error-utils.js: Centralized error handling
- event-handlers.js: User event management
- focus-utils.js: Focus and selection handling
- recording-utils.js: Audio recording functionalities
- text-processing.js: Text processing
- text-translation.js: Translation and rephrasing
- transcription-display.js: Displaying results
Transformation of content.js into a lightweight wrapper that:
- Imports and initializes the modules
- Exposes the main functions through the
BabelFishAInamespace - Keeps only the initialization functions specific to the content script
Technical improvements:
- Better separation of concerns
- Reduced circular dependencies
- Improved function documentation
- More robust error handling
- Preservation of all existing features
This refactoring facilitates future developments while maintaining compatibility with previous versions.
1.1.16
1.1.15
Fix: Improve automatic copy handling based on context
Improves the behavior of the "Automatic copy to clipboard" option to work more intuitively and contextually:
No longer automatically copies when the text is inserted into an input field.
Automatically copies only when the dialog box is displayed AND no input field is in focus.
Improves detection of valid input fields (inputs, textareas, contentEditable elements).
Respects user display preferences (forces dialog display on certain domains).
This change ensures a better user experience by avoiding unnecessary replacement of clipboard content when the text is already inserted in a field.
1.1.14
1.1.13
UI Enhancement: Moving controls to the top of the dialog box
- Copy button now accessible at the top of the dialog box
- Reduced spacing and margins for a more compact interface
- Optimized layout of controls (timer and "keep open" option)
- Better user experience for long texts without having to scroll
v1.1.12
Major Improvements:
-
Context Menu Feature:
The most significant addition is the implementation of a context menu (right-click on selected text). This menu offers two options:- Rephrase Selection: Enhances the style and clarity of the selected text using OpenAI's GPT API.
- Translate Selection: Translates the selected text into a chosen language via a submenu. The available languages are those already supported by the extension.
The original text is directly replaced by the rephrased/translated text on the web page.
-
Enhanced Dialog Box:
The dialog box (used as an alternative to direct insertion into the text field) has been significantly improved:- Visual Timer: A visual countdown (progress bar) indicates the time remaining before the dialog box automatically closes.
- "Keep Open" Option: A switch allows the user to disable automatic closing and keep the dialog box open indefinitely. The timer then transforms into an "infinite" indicator.
- Copy Button: A button allows the user to easily copy the transcribed/translated text to the clipboard.
- Aesthetic Improvements: The dialog box now features a more modern style (rounded borders, shadows, better organization).
-
Improved Error and Connection Management:
- Connection Check: Before making an API call, the code now explicitly checks whether the device is online using navigator.onLine. This prevents unnecessary API call attempts and improves the offline user experience.
- Clearer Error Messages: Error messages (for example, for API key issues, network errors, etc.) have been enhanced to be more informative and to help the user resolve problems. Specific suggestions are provided (e.g., checking the API key, verifying the internet connection).
- Automatic Retries: In the event of a temporary network error, the extension automatically retries the API call after a short pause (1.5 seconds).
-
Code Refactoring and Organization:
- Separate Language Files: The supported languages are now defined in separate files (src/utils/languages-shared.js for the content script and src/utils/languages-data.js for the service worker), which makes the code cleaner and easier to maintain. The service worker loads languages-data.js via importScripts.
- Centralized Constants: Constants (for states, actions, etc.) are defined in src/constants.js, improving readability and maintainability.
- UI Utilities: Utility functions for managing the user interface (banner, dialog box) have been grouped in src/utils/ui.js.
- Modularization: The code is overall better structured and modularized, making it easier to understand and modify.
- Updated README Files: The README files (in various languages) have been updated to reflect the new features, particularly the context menu and dialog box options.
-
Security:
- Uses window.clearTimeout instead of clearTimeout for enhanced security.
- Employs secure methods to access timers and prevent object injection.
-
Minor Changes:
- The extension version has been updated from 1.1.11 to 1.1.12.
- The type
"module"has been removed from the service_worker definition in manifest.json. - Some CSS style adjustments have been made for the dialog box.
- Improvements have been implemented in the management of the dialog box timer (no more requestAnimationFrame, cleaner timer management).
- Unused or commented-out code has been removed.
1.1.11
Features:
- Added automatic text rephrasing via GPT models to improve clarity and fluidity.
- Added direct buttons on the banner to enable/disable rephrasing and translation.
- Integrated a language selector in the banner to easily change the target language.
- Supported the Escape key to cancel the ongoing recording.
Improvements:
- Automatically hide the banner 4 seconds after the recording is cancelled.
- Bidirectional synchronization between the options and the control banner.
- Visual redesign of the banner with modern buttons and smooth animations.
- Visual optimization of the language selector (removal of double arrows).
- Added padding to the body to prevent the banner from covering content.
Internationalization:
- Added translated messages for the new features.
- Created an event system for dynamic translation management.
Framework:
- Updated constants to include rephrasing errors.
- Added a keyboard handler for detecting the Escape key.
- Improved the text processing flow to include the rephrasing step.
Fix: Preservation of Focus and Cursor during Banner Interactions
This update fixes a significant user experience issue where focus and cursor position were lost during interactions with the banner controls (rephrasing, translation buttons, language selector).
Improvements made:
- Added a system to memorize and restore focus and text selection.
- Captured focus on mousedown before interacting with controls.
- Intelligent restoration of cursor position after the interaction.
- Improved handling of delays (300ms) to ensure DOM stabilization.
- Specific management of the language selector, including cases where the user clicks elsewhere after it is opened.
- Double restoration of focus when cancelling recording with the Escape key.
- Robust checks to avoid errors on invalid elements.
These improvements ensure a smooth text editing experience without interruption, even when interacting with the extension's controls.
-
Consolidation of Duplicated Functions:
- The
showBannerfunction has been consolidated inui.jsand is now used bycontent.js. - The language lists have been centralized in a new module
languages.js.
- The
-
Extraction of CSS:
- The inline CSS in
content.jshas been moved tocontent.css. - Manual CSS injection in
content.jshas been replaced by using an external CSS file.
- The inline CSS in
-
Improvement in Module Loading:
- The file
languages.jshas been added to the list of files to inject inbackground.js. - The
i18n.jsmodule is now explicitly loaded inbackground.js.
- The file
Benefits of these changes:
-
Better Separation of Concerns:
- Display logic is now in
ui.js. - Language data is centralized in
languages.js. - Styles are managed in
content.css.
- Display logic is now in
-
Easier Maintenance:
- It is now simpler to modify styles because they are in a dedicated CSS file.
- Changes to user interface functions can be made in one place.
-
Improved Performance:
- CSS is now injected by Chrome in an optimized manner.
- Code duplication has been reduced.
-
Consolidation of Duplicated Functions:
- The
showBannerfunction has been consolidated inui.jsand is now used bycontent.js. - The language lists have been centralized in a new module
languages.js.
- The
-
Extraction of CSS:
- The inline CSS in
content.jshas been moved tocontent.css. - Manual CSS injection in
content.jshas been replaced by using an external CSS file.
- The inline CSS in
-
Modularization of the
initBannerFunction:- The long
initBannerfunction has been decomposed into several smaller, specialized functions:createBannerButton: Creates a control button with an icon and text.createLanguageSelector: Creates the language selector.initializeLanguageSelector: Initializes the selector with the available languages.setupBannerEventListeners: Sets up event handlers for the buttons.- Additional utility functions for handling languages.
- The long
-
Code Cleanup:
- Removed obsolete comments.
- Removed unnecessary skipcq markers.
-
Improved Readability:
- Better organization of functions.
- Clearer documentation.
These improvements have led to:
- Reduced code duplication.
- Improved modularity and readability.
- Easier future maintenance.
- Reduced code size.
Additional Optimizations Implemented:
-
Enhancement of the
handleActiveElementInsertionFunction:- Reduced conditional checks.
- Utilized destructuring to extract properties from elements.
- Implemented a better insertion strategy for contentEditable elements with fallback.
-
Optimization of the
insertTextIntoInputFunction:- Simplified validation conditions.
- Reduced code duplication for different insertion strategies.
- Used destructuring to extract element values.
- Calculated the new value only once regardless of the execution path.
-
Optimization of
updateBannerColorOptions:- Early exit if the banner is unavailable.
- Used a direct loop instead of
Object.keys().forEach(). - Simplified change verification.
-
Major Optimization of
handleStorageChanges:- Cached DOM selectors to avoid repeated queries.
- Employed a lazy-loading model for DOM elements.
- Grouped DOM manipulations within
requestAnimationFrame. - Optimized CSS animations.
- Implemented more robust error handling.
Benefits:
-
Better Performance:
- Fewer repetitive DOM operations.
- More efficient use of modern browser APIs.
- Reduced style recalculations and reflows.
-
More Robust Code:
- Improved error and edge-case checks.
- Reduced risk of diverging duplicated code.
- Enhanced error handling.
-
Easier Maintainability:
- More modular organization.
- Clearer separation of concerns.
- More readable code with explicit comments.
-
Resource Savings:
- Minimized object creation.
- Better memory utilization.
- Fewer garbage collection triggers.
1.1.10
Translation:
-
Addition of the 'Automatic' option for the source language in the translation settings.
-
Added the 'Automatic' option to the source language dropdown menu in the options page.
-
Added the translation for the 'Automatic' option in all
messages.jsonfiles for all supported languages. -
Modified the
translateTextfunction intranslation.jsto handle the 'Automatic' mode for the source language using an appropriate GPT prompt. -
Set the default source language to 'Automatic' in
options.js.
Fix:
- The 10-second timeout configured for API calls in
src/utils/api.jswas mistakenly added. - Completely removed the timeout to allow longer transcriptions without interruption.