Last active
October 19, 2020 16:40
-
-
Save mdamien/7decc5939556d87a1873fd69cc647d26 to your computer and use it in GitHub Desktop.
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
fetch("https://www.nosdeputes.fr/deputes/json").then(data => data.json()).then(data => { | |
DEPUTES = {} | |
data.deputes.forEach(dep => { | |
dep = dep.depute | |
DEPUTES[dep.nom_de_famille.toUpperCase()] = dep.groupe_sigle | |
}) | |
function process() { | |
document.querySelectorAll("#amdtAuteur").forEach(x => { | |
if (!x.hasAttribute("processed")) { | |
var nom = x.innerText.replace("de", "").replace(" et plusieurs de ses collègues", "").replace("M.", "").replace("Mme", "") | |
nom = nom.toUpperCase().trim() | |
console.log(nom, DEPUTES[nom]) | |
if (DEPUTES[nom]) { | |
x.innerHTML += "(" + DEPUTES[nom] + ")" | |
} | |
x.setAttribute("processed", "true") | |
} | |
}) | |
document.querySelectorAll("#auteur").forEach(x => { | |
if (!x.hasAttribute("processed")) { | |
var nom = x.innerText.replace("de", "").replace(" et plusieurs de ses collègues", "").replace("M.", "").replace("Mme", "") | |
nom = nom.toUpperCase().trim() | |
console.log(nom, DEPUTES[nom]) | |
if (DEPUTES[nom]) { | |
x.querySelector(".left").innerHTML += " <small> (" + DEPUTES[nom] + ")</small>" | |
} | |
x.setAttribute("processed", "true") | |
} | |
}) | |
setTimeout(process, 100) | |
} | |
process() | |
}) | |
/* allez sur https://caiorss.github.io/bookmarklet-maker/ pour en faire un bookmark */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
C pas hyper pérenne, ajoute un call à l'api de ND pour remplacer la première ligne plutot non ?