Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save w3spi5/4fbeef1b1d5d54497f2e0918b52fd643 to your computer and use it in GitHub Desktop.

Select an option

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...)
// 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');
}
@w3spi5
Copy link
Author

w3spi5 commented Nov 1, 2025

📖 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:

  • Press F12 or Ctrl+Shift+J (Windows/Linux)
  • Press Cmd+Option+J (Mac)

Open DevTools Console

Step 2: Copy-paste the script

  • Copy all the code from the france-travail-change-password-enable-copy-paste.js file
  • Paste it into the console
  • Press Enter

Code pasted in console

Step 3: Enter the field name

  • A popup appears asking for the name of the field
  • How to find the name?
    - Right-click on the field → "Inspect"
    - Look for the name="..." attribute in the HTML code
    - Copy this value

Inspect element to find the name

Inspect element to find the name

Popup asking for the name

Step 4: Check the result

  • A ✅ message confirms activation in the console
  • You can now copy-paste in the field!

Confirmation message

You can now paste

  • Do the same for the next field

Next field

  • A ✅ message confirms activation in the console
  • You can now copy-paste in the field!

You can now paste

💡 Common name examples

  • email
  • password
  • username
  • confirm-password

⚠️ Important notes

  • This script only works on the current page
  • You need to run it again if you reload the page
  • Some websites may have additional protections

🔧 Alternative: Bookmarklet

To use it with one click, create a bookmark with this code in the URL:

javascript:(function(){const elementName=prompt("Enter the 'name' of the input or textarea:");if(elementName){const elements=document.getElementsByName(elementName);if(elements.length>0){const element=elements[0];if(element.tagName==='INPUT'||element.tagName==='TEXTAREA'){element.style.webkitUserSelect='text';element.style.userSelect='text';const allowEvent=(e)=>{e.stopImmediatePropagation();return true;};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);['oncopy','onpaste','oncut','onselectstart','oncontextmenu'].forEach(attr=>{if(element.hasAttribute(attr)){element.removeAttribute(attr);}});console.log(`✅ Copy-paste enabled!`);}}}})();

🔧 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment