Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@corsonr
Last active January 16, 2021 08:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corsonr/80566e8864022c22954e63954b2dd1c8 to your computer and use it in GitHub Desktop.
Save corsonr/80566e8864022c22954e63954b2dd1c8 to your computer and use it in GitHub Desktop.
Génération automatique de l'attestation dérogatoire obligatoire en France pour le confinement V2.
// ==UserScript==
// @name Attestation Derogatoire
// @namespace https://media.interieur.gouv.fr/
// @version 0.1
// @description Auto-génération de l'attestation. Passez le motif en URL, par exemple https://media.interieur.gouv.fr/deplacement-covid-19/?raison=travail
// @author Remi Corson
// @match https://media.interieur.gouv.fr/*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
$(document).ready(function() {
// Récupération des paramètres d'URL.
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
// Récupération de l'heure.
var date = new Date();
var hour = date.getHours();
var minutes = date.getMinutes();
// Remplissage des champs (la date est déja indiqué par le site officiel).
$("input[name='firstname']").val('Votre prenom');
$("input[name='lastname']").val('Votre nom');
$("input[name='birthday']").val('29/01/1981');
$("input[name='placeofbirth']").val('Ville de naissance');
$("input[name='address']").val('Votre adresse');
$("input[name='city']").val('Votre ville de résidence');
$("input[name='zipcode']").val('75000');
$("input[name='heuresortie']").val( hour + ':' + minutes );
// Motif de la sortie à indiquer dans l'url.
// Exemple: https://media.interieur.gouv.fr/deplacement-covid-19/?raison=travail
var raison = getUrlParameter('raison');
if (raison == 'travail' ) {
$("#checkbox-travail").prop("checked", true);
}
if (raison == 'achats' ) {
$("#checkbox-achats").prop("checked", true);
}
if (raison == 'sante' ) {
$("#checkbox-sante").prop("checked", true);
}
if (raison == 'famille' ) {
$("#checkbox-famille").prop("checked", true);
}
if (raison == 'handicap' ) {
$("#checkbox-handicap").prop("checked", true);
}
if (raison == 'sport_animaux' ) {
$("#checkbox-sport_animaux").prop("checked", true);
}
if (raison == 'convocation' ) {
$("#checkbox-convocation").prop("checked", true);
}
if (raison == 'missions' ) {
$("#checkbox-missions").prop("checked", true);
}
if (raison == 'enfants' ) {
$("#checkbox-enfants").prop("checked", true);
}
// Simulation du click sur le bouton "Générer mon attestation".
$("#generate-btn").click()
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment