Skip to content

Instantly share code, notes, and snippets.

@vincevargadev
Last active January 28, 2020 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vincevargadev/e6c1325075d3a58da10293efa272a78e to your computer and use it in GitHub Desktop.
Save vincevargadev/e6c1325075d3a58da10293efa272a78e to your computer and use it in GitHub Desktop.
Get first and last names from meetup event
/**
* 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