Last active
January 28, 2020 21:14
-
-
Save vincevargadev/e6c1325075d3a58da10293efa272a78e to your computer and use it in GitHub Desktop.
Get first and last names from meetup event
This file contains hidden or 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
/** | |
* HOW TO USE IT | |
* Go the your event, then select attendee list. | |
* Make sure you are on the "Going" tab. | |
*/ | |
const $attendees = Array.from(document.querySelectorAll('h4.text--ellipsisOneLine')); | |
// Sorted names. | |
// Start with long names, then leave the names with no spaces to the end. | |
// These tend to be the fake names, in case they are obviously fake names, | |
// you remove them from the list. | |
const names = $attendees | |
.map(i => i.innerText) | |
.sort() | |
.sort((a, b) => b.split(' ').length - a.split(' ').length); | |
function firstNames(t) { | |
const x = t.split(' '); | |
if (x.length === 1) return x[0]; | |
if (x.length == 2) return x[0]; | |
if (x.length > 2) return `${x[0]} ${x[1]}`; | |
} | |
function lastNames(t) { | |
const x = t.split(' '); | |
if (x.length === 1) return ''; | |
if (x.length == 2) return x[1]; | |
if (x.length > 2) return x.slice(2).join(' '); | |
} | |
const printFirstNames = () => names.map(firstNames).join('\n'); | |
const printLastNames = () => names.map(lastNames).join('\n'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment