✨ feat: Implémentation de la correction via le menu contextuel et améliorations de la construction
- ✨ Ajout de la fonctionnalité de correction via le menu contextuel. - 🗑️ Suppression de la fonctionnalité de correction en temps réel. - ➕ Ajout du script de fond (background.js) pour gérer le menu contextuel. - 📝 Mise à jour du manifest.json (permissions, service_worker, description). - 🐛 Correction de la logique de remplacement de texte dans content.js pour une meilleure compatibilité. - 🏗️ Mise à jour du Dockerfile pour construire l'extension Chrome dans un répertoire (non zippé). - 🛠️ Mise à jour du script build.sh pour gérer le nouveau format de sortie et nettoyer le répertoire. - 🌐 Traduction du manifest.json en français. - 📄 Ajout d'un README.md complet avec les instructions d'installation. - 🐛 Ajout de logs pour faciliter le débogage.
This commit is contained in:
commit
9840633305
13 changed files with 412 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
chrome-extension.zip
|
||||
output/
|
||||
.DS_Store
|
32
Dockerfile
Normal file
32
Dockerfile
Normal file
|
@ -0,0 +1,32 @@
|
|||
# Stage 1: The Builder
|
||||
# This stage takes a lightweight Alpine Linux image, installs the 'zip' utility,
|
||||
# and then copies your extension files into it to create the packages.
|
||||
FROM alpine:latest AS builder
|
||||
|
||||
# Set the working directory inside the container.
|
||||
WORKDIR /extension
|
||||
|
||||
# Copy all the extension files into the working directory.
|
||||
# Ensure your Dockerfile is in the same directory as these files.
|
||||
COPY manifest.json .
|
||||
COPY popup.html .
|
||||
COPY popup.js .
|
||||
COPY content.js .
|
||||
COPY background.js .
|
||||
COPY images/ ./images/
|
||||
|
||||
# Stage 2: The Final Package
|
||||
# This stage is a minimal image whose only purpose is to hold the final packages.
|
||||
# Using alpine instead of scratch and adding a CMD makes it easier to interact with.
|
||||
FROM alpine:latest
|
||||
|
||||
# Set the output directory.
|
||||
WORKDIR /output
|
||||
|
||||
# Create a subdirectory for the Chrome extension and copy all files into it.
|
||||
RUN mkdir chrome-extension
|
||||
COPY --from=builder /extension/ ./chrome-extension/
|
||||
|
||||
# Add a default command to list the contents of the output directory.
|
||||
# This makes the container runnable and prevents the "no command specified" error.
|
||||
CMD ["ls", "-l"]
|
73
LICENSE
Normal file
73
LICENSE
Normal file
|
@ -0,0 +1,73 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||
|
||||
Copyright 2025 jevalideca
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
50
README.md
Normal file
50
README.md
Normal file
|
@ -0,0 +1,50 @@
|
|||
# Outil d'écriture inclusive en français
|
||||
|
||||
Cette extension Chrome convertit le texte sélectionné pour utiliser le point médian inclusif (·) via un menu contextuel.
|
||||
|
||||
## Fonctionnalités
|
||||
|
||||
* Conversion du texte sélectionné en écriture inclusive (point médian).
|
||||
* Intégration via le menu contextuel du navigateur.
|
||||
|
||||
## Installation
|
||||
|
||||
Suivez ces étapes pour installer et utiliser l'extension dans votre navigateur Chrome.
|
||||
|
||||
### Prérequis
|
||||
|
||||
* [Docker](https://www.docker.com/get-started) : Utilisé pour construire l'extension dans un environnement isolé.
|
||||
|
||||
### Étapes de construction
|
||||
|
||||
1. **Cloner le dépôt** (si ce n'est pas déjà fait) :
|
||||
```bash
|
||||
git clone [URL_DE_VOTRE_DEPOT]
|
||||
cd point-median-extension
|
||||
```
|
||||
*(Remplacez `[URL_DE_VOTRE_DEPOT]` par l'URL réelle de votre dépôt Git.)*
|
||||
|
||||
2. **Construire l'extension** :
|
||||
Exécutez le script de construction. Cela va créer un dossier `output/chrome-extension` contenant tous les fichiers nécessaires à l'extension.
|
||||
```bash
|
||||
./build.sh
|
||||
```
|
||||
|
||||
### Chargement de l'extension dans Chrome
|
||||
|
||||
1. **Ouvrez Chrome** et naviguez vers `chrome://extensions`.
|
||||
2. **Activez le "Mode développeur"** en basculant l'interrupteur situé en haut à droite de la page.
|
||||
3. Cliquez sur le bouton **"Charger l'extension non empaquetée"** (Load unpacked).
|
||||
4. Dans la boîte de dialogue qui apparaît, naviguez jusqu'au répertoire de votre projet et sélectionnez le dossier `output/chrome-extension` que vous avez créé à l'étape de construction.
|
||||
5. L'extension "Outil d'écriture inclusive en français" devrait maintenant apparaître dans votre liste d'extensions.
|
||||
|
||||
### Utilisation
|
||||
|
||||
1. Sélectionnez du texte sur n'importe quelle page web.
|
||||
2. Faites un clic droit sur le texte sélectionné.
|
||||
3. Dans le menu contextuel, sélectionnez **"Convertir en écriture inclusive"**.
|
||||
4. Le texte sélectionné sera remplacé par sa version inclusive.
|
||||
|
||||
## Dépannage
|
||||
|
||||
Si l'extension ne fonctionne pas comme prévu, vérifiez la console du navigateur (Ctrl+Maj+I ou Cmd+Option+I, puis onglet "Console") et la console du service worker de l'extension (cliquez sur "Inspecter la vue" ou "Service Worker" sous l'extension dans `chrome://extensions`) pour d'éventuels messages d'erreur.
|
43
background.js
Normal file
43
background.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
chrome.runtime.onInstalled.addListener(() => {
|
||||
console.log("Background script: Extension installed or updated.");
|
||||
chrome.contextMenus.create({
|
||||
id: "convertText",
|
||||
title: "Convertir en écriture inclusive",
|
||||
contexts: ["selection"]
|
||||
});
|
||||
console.log("Background script: Context menu item created.");
|
||||
});
|
||||
|
||||
chrome.contextMenus.onClicked.addListener((info, tab) => {
|
||||
console.log("Background script: Context menu item clicked.", info);
|
||||
if (info.menuItemId === "convertText" && info.selectionText && tab && tab.id) {
|
||||
console.log(`Background script: Selected text: "${info.selectionText}" in tab ID: ${tab.id}`);
|
||||
// First, ensure the content script is injected into the tab.
|
||||
// This is crucial if the tab was opened before the extension was installed/updated,
|
||||
// or if the content script somehow failed to load.
|
||||
chrome.scripting.executeScript({
|
||||
target: { tabId: tab.id },
|
||||
files: ['content.js']
|
||||
}, () => {
|
||||
// Check for runtime.lastError to see if injection failed
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error("Background script: Error injecting content script:", chrome.runtime.lastError.message);
|
||||
return;
|
||||
}
|
||||
console.log("Background script: Content script injected/confirmed.");
|
||||
// After the content script is (re)injected, send the message.
|
||||
chrome.tabs.sendMessage(tab.id, {
|
||||
action: "convertSelectedText",
|
||||
text: info.selectionText
|
||||
}).then(response => {
|
||||
console.log("Background script: Message sent to content script. Response:", response);
|
||||
}).catch(error => {
|
||||
// Catch potential errors if the receiving end still doesn't exist
|
||||
// (e.g., tab closed immediately after context menu click).
|
||||
console.error("Background script: Error sending message to content script:", error);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.log("Background script: Context menu click conditions not met.");
|
||||
}
|
||||
});
|
12
build.sh
Executable file
12
build.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
# Clean up previous build artifacts
|
||||
rm -rf output
|
||||
|
||||
# Build the image
|
||||
docker build -t extension-packager .
|
||||
|
||||
# Create the output directory if it doesn't exist
|
||||
mkdir -p output
|
||||
|
||||
ID=$(docker create extension-packager)
|
||||
docker cp $ID:/output/chrome-extension ./output/chrome-extension
|
||||
docker rm -v $ID
|
122
content.js
Normal file
122
content.js
Normal file
|
@ -0,0 +1,122 @@
|
|||
/**
|
||||
* This content script handles the conversion of selected text to use the inclusive middle dot.
|
||||
* It receives messages from the background script to perform the conversion.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Converts text to use the inclusive middle dot (·).
|
||||
* This function contains the original conversion logic.
|
||||
* @param {string} texte The input text.
|
||||
* @returns {string} The converted text.
|
||||
*/
|
||||
function convertirPointMedian(texte) {
|
||||
let currentText = texte;
|
||||
const sep = /[.\-]/; // Recognizes '.' or '-' as separators
|
||||
|
||||
// Rules with 3 components (e.g., "mot.e.s")
|
||||
const regles3 = [
|
||||
{ find: new RegExp(`(\\w+)${sep.source}(\\w+[es]*)${sep.source}([es]+)`, 'g'), replace: '$1·$2·$3' },
|
||||
{ find: new RegExp(`([td]eur)${sep.source}([td]rice)${sep.source}([s]+)`, 'g'), replace: '$1·$2·$3' },
|
||||
{ find: new RegExp(`(eur)${sep.source}(ice|euse)${sep.source}([s]+)`, 'g'), replace: '$1·$2·$3' },
|
||||
{ find: new RegExp(`(er)${sep.source}(ère)${sep.source}([s]+)`, 'g'), replace: '$1·$2·$3' },
|
||||
{ find: new RegExp(`([fs])${sep.source}([fs]{2}e)${sep.source}([s]+)`, 'g'), replace: '$1·$2·$3' },
|
||||
{ find: new RegExp(`([eo][lnt])${sep.source}([eo]?[lnt]+e)${sep.source}([s]+)`, 'g'), replace: '$1·$2·$3' }
|
||||
];
|
||||
regles3.forEach(rule => { currentText = currentText.replace(rule.find, rule.replace); });
|
||||
|
||||
// Rules with 2 components (e.g., "mot.s")
|
||||
const regles2 = [
|
||||
{ find: new RegExp(`(\\w+)${sep.source}([es]+)`, 'g'), replace: '$1·$2' },
|
||||
{ find: new RegExp(`([td]eur[s]?)${sep.source}([td]?rice[s]?)`, 'g'), replace: '$1·$2' },
|
||||
{ find: new RegExp(`(eur[s]?)${sep.source}(euse[s]?|ice[s]?)`, 'g'), replace: '$1·$2' },
|
||||
{ find: new RegExp(`(eux|el)${sep.source}(elle[s]?|euse[s]?|le[s]?)`, 'g'), replace: '$1·$2' },
|
||||
{ find: new RegExp(`(aux|al)${sep.source}(ale[s]?)`, 'g'), replace: '$1·$2' },
|
||||
{ find: new RegExp(`(er[s]?)${sep.source}(ère[s]?)`, 'g'), replace: '$1·$2' },
|
||||
{ find: new RegExp(`([s])${sep.source}([s]{2}e[s]?)`, 'g'), replace: '$1·$2' },
|
||||
{ find: new RegExp(`([eo][flnt][s]?)${sep.source}([eo]?[flnt]+e[s]?)`, 'g'), replace: '$1·$2' },
|
||||
{ find: new RegExp(`(\\w+e)${sep.source}(\\w+a)`, 'g'), replace: '$1·$2' },
|
||||
{ find: new RegExp(`(\\w+t)${sep.source}(te)`, 'g'), replace: '$1·$2' }
|
||||
];
|
||||
regles2.forEach(rule => { currentText = currentText.replace(rule.find, rule.replace); });
|
||||
|
||||
// Rules using parentheses (e.g., "mot(s)")
|
||||
const reglesp = [
|
||||
{ find: /(\w+)[\(]([es]+)[\)]/g, replace: '$1·$2' },
|
||||
{ find: /([td]eur[s]?)[\(]([td]?rice[s]?)[\)]/g, replace: '$1·$2' },
|
||||
{ find: /(eur[s]?)[\(](euse[s]?|ice[s]?)[\)]/g, replace: '$1·$2' },
|
||||
{ find: /(eux|el)[\(](elle[s]?|euse[s]?|le[s]?)[\)]/g, replace: '$1·$2' },
|
||||
{ find: /(aux|al)[\(](ale[s]?)[\)]/g, replace: '$1·$2' },
|
||||
{ find: /(er[s]?)[\(](ère[s]?)[\)]/g, replace: '$1·$2' },
|
||||
{ find: /([s])[\(]([s]{2}e[s]?)[\)]/g, replace: '$1·$2' },
|
||||
{ find: /([eo][flnt][s]?)[\(]([eo]?[flnt]+e[s]?)[\)]/g, replace: '$1·$2' },
|
||||
{ find: /(\w+e)[\(](\w+a)[\)]/g, replace: '$1·$2' },
|
||||
{ find: /(\w+t)[\(](te)[\)]/g, replace: '$1·$2' }
|
||||
];
|
||||
reglesp.forEach(rule => { currentText = currentText.replace(rule.find, rule.replace); });
|
||||
|
||||
return currentText;
|
||||
}
|
||||
|
||||
// Listen for messages from the background script.
|
||||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
console.log("Content script: Message received.", request);
|
||||
if (request.action === "convertSelectedText" && request.text) {
|
||||
console.log(`Content script: Converting text: "${request.text}"`);
|
||||
const convertedText = convertirPointMedian(request.text);
|
||||
console.log(`Content script: Converted text: "${convertedText}"`);
|
||||
|
||||
// Try to use document.execCommand for better compatibility with contenteditable elements
|
||||
// and to maintain undo/redo history.
|
||||
if (document.execCommand('insertText', false, convertedText)) {
|
||||
console.log("Content script: Text replaced using execCommand.");
|
||||
// If execCommand was successful, dispatch an input event to notify frameworks.
|
||||
const activeElement = document.activeElement;
|
||||
if (activeElement) {
|
||||
activeElement.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
console.log("Content script: Dispatched input event.");
|
||||
}
|
||||
sendResponse({ success: true, newText: convertedText });
|
||||
} else {
|
||||
// Fallback for elements where execCommand might not work or for direct text selections.
|
||||
console.log("Content script: execCommand failed, falling back to window.getSelection.");
|
||||
const selection = window.getSelection();
|
||||
if (selection.rangeCount > 0) {
|
||||
const range = selection.getRangeAt(0);
|
||||
range.deleteContents(); // Remove the selected text
|
||||
range.insertNode(document.createTextNode(convertedText)); // Insert the new text
|
||||
console.log("Content script: Text replaced using window.getSelection.");
|
||||
|
||||
// Manually dispatch an input event if the target is an editable element
|
||||
// and execCommand didn't handle it.
|
||||
const activeElement = document.activeElement;
|
||||
if (activeElement && (activeElement.isContentEditable ||
|
||||
activeElement.tagName.toLowerCase() === 'textarea' ||
|
||||
(activeElement.tagName.toLowerCase() === 'input' && /text|search|email|url|tel/.test(activeElement.type)))) {
|
||||
activeElement.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
console.log("Content script: Dispatched input event (fallback).");
|
||||
}
|
||||
sendResponse({ success: true, newText: convertedText });
|
||||
} else {
|
||||
console.log("Content script: No selection found for fallback replacement.");
|
||||
sendResponse({ success: false, error: "No selection found." });
|
||||
}
|
||||
}
|
||||
|
||||
// After replacement, clear the selection to prevent accidental re-insertion
|
||||
// or issues with the "buffer" as described by the user.
|
||||
const selection = window.getSelection();
|
||||
if (selection) {
|
||||
selection.empty(); // For Chrome/Safari
|
||||
if (selection.removeAllRanges) { // For Firefox
|
||||
selection.removeAllRanges();
|
||||
}
|
||||
console.log("Content script: Selection cleared.");
|
||||
}
|
||||
|
||||
} else {
|
||||
console.log("Content script: Message not for text conversion or missing text.", request);
|
||||
sendResponse({ success: false, error: "Invalid request." });
|
||||
}
|
||||
// Return true to indicate that sendResponse will be called asynchronously.
|
||||
return true;
|
||||
});
|
BIN
images/icon128.png
Normal file
BIN
images/icon128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
images/icon16.png
Normal file
BIN
images/icon16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 376 B |
BIN
images/icon48.png
Normal file
BIN
images/icon48.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
40
manifest.json
Normal file
40
manifest.json
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Outil d'écriture inclusive en français",
|
||||
"version": "1.1",
|
||||
"description": "Convertit automatiquement le texte pour utiliser le point médian inclusif (·) pendant la saisie.",
|
||||
"permissions": [
|
||||
"storage",
|
||||
"activeTab",
|
||||
"scripting",
|
||||
"contextMenus"
|
||||
],
|
||||
"background": {
|
||||
"service_worker": "background.js",
|
||||
"type": "module"
|
||||
},
|
||||
"action": {
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": {
|
||||
"16": "images/icon16.png",
|
||||
"48": "images/icon48.png",
|
||||
"128": "images/icon128.png"
|
||||
}
|
||||
},
|
||||
"icons": {
|
||||
"16": "images/icon16.png",
|
||||
"48": "images/icon48.png",
|
||||
"128": "images/icon128.png"
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": [
|
||||
"<all_urls>"
|
||||
],
|
||||
"js": [
|
||||
"content.js"
|
||||
],
|
||||
"run_at": "document_idle"
|
||||
}
|
||||
]
|
||||
}
|
29
popup.html
Normal file
29
popup.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Inclusive French Tool</title>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
width: 320px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-slate-50 p-4">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-base font-semibold text-slate-800">Real-time Conversion</span>
|
||||
<label for="enabled-toggle" class="relative inline-flex items-center cursor-pointer">
|
||||
<input type="checkbox" value="" id="enabled-toggle" class="sr-only peer">
|
||||
<div class="w-11 h-6 bg-gray-200 rounded-full peer peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-blue-400 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-0.5 after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
|
||||
</label>
|
||||
</div>
|
||||
<p class="text-sm text-slate-600 mt-2">
|
||||
When enabled, the extension will automatically convert text like "auteur.e.s" to "auteur·e·s" as you type.
|
||||
</p>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
8
popup.js
Normal file
8
popup.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* This script handles the logic for the extension's popup.
|
||||
* As the real-time conversion is removed, this popup is now minimal.
|
||||
*/
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// No specific functionality needed for the popup with context menu approach.
|
||||
// This script can be removed or kept minimal if no UI elements are required.
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue