Skip to content

Instantly share code, notes, and snippets.

@mdamien
Last active October 19, 2020 16:40
Show Gist options
  • Save mdamien/7decc5939556d87a1873fd69cc647d26 to your computer and use it in GitHub Desktop.
Save mdamien/7decc5939556d87a1873fd69cc647d26 to your computer and use it in GitHub Desktop.
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 += "&nbsp;<small>&nbsp;(" + DEPUTES[nom] + ")</small>"
}
x.setAttribute("processed", "true")
}
})
setTimeout(process, 100)
}
process()
})
/* allez sur https://caiorss.github.io/bookmarklet-maker/ pour en faire un bookmark */
@RouxRC
Copy link

RouxRC commented Oct 19, 2020

C pas hyper pérenne, ajoute un call à l'api de ND pour remplacer la première ligne plutot non ?

@mdamien
Copy link
Author

mdamien commented Oct 19, 2020

@RouxRC done 👍 :)

@RouxRC
Copy link

RouxRC commented Oct 19, 2020

Yeah! :)

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