Skip to content

Instantly share code, notes, and snippets.

@samuelguebo
Last active May 13, 2020 21:27
Show Gist options
  • Save samuelguebo/bf2a3201c9f7baa795c6284b999aae03 to your computer and use it in GitHub Desktop.
Save samuelguebo/bf2a3201c9f7baa795c6284b999aae03 to your computer and use it in GitHub Desktop.
/**
* "Active Users" are registered users who have made at least
* one edit in the last thirty days.
*/
let apiURI = 'https://meta.wikimedia.org/w/api.php?action=parse&page=List%20of%20Wikipedias&origin=*&format=json'
fetch(apiURI)
.then(res => res.json())
.then(data => {
data = data.parse.text['*']
let page = document.createElement('html')
page.innerHTML = data
let projects = page.querySelectorAll('table tbody tr td:nth-child(10)')
let total = 0
projects.forEach(project => {
total += parseFloat(project.innerText.replace(',', ''))
})
return total
})
.then(total => console.log(`total of active contributors: ${total}`))
.catch(error => console.log(error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment