Last active
August 13, 2022 11:37
-
-
Save jgusta/0d88f95288ce126e34c80d498c1d9f80 to your computer and use it in GitHub Desktop.
Run in console of Discord browser app to get a list of all users in the room.
This file contains 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
(function () { | |
return new Promise(async (final) => { | |
const list = await new Promise((res) => { | |
let l = document.querySelectorAll("[aria-label=Members]")[0] | |
.parentElement; | |
l.scrollTo({ top: 0, left: 0, behavior: "instant" }); | |
setTimeout(() => res(l), 500); | |
}); | |
let names = []; | |
const height = list.scrollHeight - window.innerHeight; | |
const movement = 200 | |
for (i = 0; i < height; i += movement) { | |
perc = ((i / height) * 100).toFixed(2); | |
console.log(`scanning names ...${perc}%`); | |
await new Promise((res) => { | |
list.scrollBy(0, movement); | |
setTimeout(()=>{res();}, 500); | |
}); | |
newnames = await new Promise((res) => { | |
let elems = Array.from( | |
document.querySelectorAll( | |
"[data-list-item-id^=members] [class^=name-] > span > span" | |
) | |
); | |
elems = elems.map((x) => x.innerHTML); | |
res(elems); | |
}); | |
names = await new Promise((res) => { | |
let x = [...names, ...newnames].reduce( | |
(prev, item) => (prev.includes(item) ? prev : [item, ...prev]), | |
[] | |
); | |
res(x); | |
}); | |
} | |
console.log(`done ...100%`); | |
final(names); | |
}); | |
})().then(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One-liner: