Created
November 1, 2025 10:26
-
-
Save w3spi5/4fbeef1b1d5d54497f2e0918b52fd643 to your computer and use it in GitHub Desktop.
France Travail : Script pour activer le copier-coller sur les champs input/textarea désactivés (et il faut l'avouer, c'est complètement débile de leur part à l'heure de l'automatisation des mots de passe autogénérés...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Demander le name de l'élément | |
| const elementName = prompt("Entrez le 'name' de l'input ou textarea :"); | |
| if (elementName) { | |
| // Rechercher l'élément par son attribut name | |
| const elements = document.getElementsByName(elementName); | |
| if (elements.length > 0) { | |
| // Prendre le premier élément trouvé | |
| const element = elements[0]; | |
| // Vérifier que c'est bien un input ou textarea | |
| if (element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') { | |
| // Permettre la sélection de texte | |
| element.style.webkitUserSelect = 'text'; | |
| element.style.userSelect = 'text'; | |
| // Intercepter et autoriser les événements | |
| const allowEvent = (e) => { | |
| e.stopImmediatePropagation(); | |
| return true; | |
| }; | |
| // Ajouter des listeners pour autoriser copier-coller | |
| element.addEventListener('copy', allowEvent, true); | |
| element.addEventListener('paste', allowEvent, true); | |
| element.addEventListener('cut', allowEvent, true); | |
| element.addEventListener('selectstart', allowEvent, true); | |
| element.addEventListener('contextmenu', allowEvent, true); | |
| // Supprimer les attributs inline | |
| ['oncopy', 'onpaste', 'oncut', 'onselectstart', 'oncontextmenu'].forEach(attr => { | |
| if (element.hasAttribute(attr)) { | |
| element.removeAttribute(attr); | |
| } | |
| }); | |
| console.log(`✅ Copier-coller activé sur l'élément avec name="${elementName}" !`); | |
| console.log(`Type: ${element.tagName}, ID: ${element.id || '(pas d\'id)'}`); | |
| } else { | |
| console.error(`❌ L'élément trouvé n'est ni un INPUT ni un TEXTAREA (c'est un ${element.tagName})`); | |
| } | |
| } else { | |
| console.error(`❌ Aucun élément trouvé avec name="${elementName}"`); | |
| } | |
| } else { | |
| console.log('❌ Opération annulée'); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
📖 France-Travail - README English Version - Password Modification - Enable Copy/Paste in Password Fields - Usage Tutorial
🎯 What is this for?
France Travail really annoys us with their policy of preventing copy/paste in their input fields for changing passwords, among other things. And with our modern random password generator solutions, manually retyping the password has become really tedious.
So I designed this script that allows you to reactivate copy-paste on form fields, and this script is specifically optimized for the URL:
"https://candidat.francetravail.fr/compte/parametres/modificationmotdepasse" (input/textarea) where this functionality has been disabled by the website. But the code below, if modified, should work on any other website, hence my OpenSource sharing via a Gist.
🚀 How to use it?
Step 1: Open DevTools Console
On Chrome/Edge/Brave:
F12orCtrl+Shift+J(Windows/Linux)Cmd+Option+J(Mac)Step 2: Copy-paste the script
france-travail-change-password-enable-copy-paste.jsfileEnterStep 3: Enter the field name
nameof the fieldname?- Right-click on the field → "Inspect"
- Look for the
name="..."attribute in the HTML code- Copy this value
Step 4: Check the result
💡 Common
nameexamplesemailpasswordusernameconfirm-password🔧 Alternative: Bookmarklet
To use it with one click, create a bookmark with this code in the URL:
🔧 Alternative 2: Automatic France Travail Bookmarklet (current code at the time of writing)
I will create a second gist allowing the possibility to automatically unlock fields on France Travail.
📄 License
This code is under MIT license. You are free to use and modify it.