Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Doing some TypeScript stuff!

Sylvain PONTOREAU spontoreau

👨‍💻
Doing some TypeScript stuff!
View GitHub Profile
@spontoreau
spontoreau / pick-a-meetup-attendee.js
Created Jan 7, 2020
A quick and dirty way to pick meetup attendee in the attendee list!
View pick-a-meetup-attendee.js
const txt = document.querySelector(".response-filter-yes span").textContent;
const nbAttendees = txt.match(/\d+/)[0];
const randomIndex = Math.floor(Math.random() * Math.floor(nbAttendees));
const attendees = document.querySelectorAll(".attendees-list li .text--bold.text--ellipsisOneLine");
const winner = attendees[randomIndex];
console.log(winner.textContent);
// or
console.log(document.querySelectorAll(".attendees-list li .text--bold.text--ellipsisOneLine")[Math.floor(Math.random() * Math.floor(document.querySelector(".response-filter-yes span").textContent.match(/\d+/)[0]))].innerText);