Created
April 6, 2020 09:50
-
-
Save eddydg/d251fed075c92e3469912dd93c04598d to your computer and use it in GitHub Desktop.
A
This file contains 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
// https://media.interieur.gouv.fr/deplacement-covid-19/ | |
/* Add custom generation time field */ | |
function updateGenHour(time) { | |
const times = time.split(":"); | |
Date.prototype.getHours=()=>times[0]; | |
Date.prototype.getMinutes=()=>times[1]; | |
} | |
const temp = document.createElement("div"); | |
temp.innerHTML = '<div class="form-group"> <label for="field-heure">Heure de génération</label> <div class="input-group align-items-center"> <input type="time" class="form-control" onchange="updateGenHour(this.value)" id="field-heuregen"> </div> </div>'; | |
const now = new Date(); | |
now.setMinutes(now.getMinutes() - 10); | |
temp.querySelector("#field-heuregen").value = now.getHours() + ":" + now.getMinutes(); | |
const anchor = document.querySelector("#form-profile > p"); | |
anchor.parentNode.insertBefore(temp.firstChild, anchor); | |
/* Bookmarklet version */ | |
function u(e){const t=e.split(":");Date.prototype.getHours=(()=>t[0]),Date.prototype.getMinutes=(()=>t[1])}const n=document.createElement("div");n.innerHTML='<div class="form-group"> <label for="field-heure">Heure de génération</label> <div class="input-group align-items-center"> <input type="time" class="form-control" onchange="u(this.value)" id="field-heuregen"> </div> </div>';const i=new Date;i.setMinutes(i.getMinutes()-10),n.querySelector("#field-heuregen").value=i.getHours()+":"+i.getMinutes();const a=document.querySelector("#form-profile > p");a.parentNode.insertBefore(n.firstChild,a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment