Updated:

I started a small project! šŸ˜€

I got the idea from a friend, who was in need of a program that can shuffle the members in a community platform called Naver BAND. So I started by creating a simple program that extracts the user names from a BAND member page and shuffles them. It works perfectly on console!

// Get member list
const ulObject = document.querySelector("#content > div > div.memberWrap > div._memberListWrap > div > ul")
let memberList = [];

// Loop through members and get the user name
const numMems = ulObject.childElementCount;
let i = 0;
while (i < numMems) {
  memberList.push(ulObject.children[i].dataset.user_name);
  i++;
}

//Discard username '.' and 'ā„'
const memberListWithoutDots = memberList.filter(
  (f) => (f !== '.' && f !== 'ā„')
)

// Shuffle the array
const shuffled = memberListWithoutDots
  .map(a => ([Math.random(),a]))
  .sort((a,b) => a[0]-b[0])
  .map(a => a[1])

// Print the array in a string
let stringShuffled = ''
shuffled.forEach(element => stringShuffled += `${element}, `);

console.log(`total members counted: ${shuffled.length}`);
console.log(stringShuffled);

My intention was to create an application with JavaScript that can be run on Chrome, and I figured out the only way to do it is by creating a chrome extension. Which is my next step!

Iā€™m thinking of adding more features like extracting n random people, grouping the members by certain criteria, and so on.

Next up:

  • Continue the Node.js crash course
  • Keep working on the project!

Tags:

Categories:

Updated:

Leave a comment