[Solved] Load all slack members into a var in JavaScript


Go to https://SLACK.slack.com/threads/team/ (replace SLACK with your slack group name)

Enter this in the console, it will scroll through the sidebar and insert the members from the sidebar into an array called storage

var storage = [];
var el = document.querySelector('#team_list_scroller');
el.scrollTop = 0;
var last_scroll;
var loop = () => {
  last_scroll = el.scrollTop;
  el.scrollTop += 30;
  storage = storage.concat(
    Array.prototype.map.call(
      document.querySelectorAll('#team_list_scroller .member_details'),
      (el) => {
        let q = el.innerText.match(/\@\w+\W/);
        if ( q && !q.length ) return '';
        return q === null ? q = '@' + el.innerText.trim() : q[0].trim();
      }
    ).filter(t => t.length && t[0] === '@' && storage.indexOf(t) < 0)
  );

  if (el.scrollTop !== last_scroll) {
    requestAnimationFrame(loop);
  } else {
    console.log(storage);
  }
};
loop();

12

solved Load all slack members into a var in JavaScript