Skip to content

Instantly share code, notes, and snippets.

@Imeguras
Created August 8, 2022 17:28
Show Gist options
  • Save Imeguras/253f74d3caa327f8040433548d5d2c2f to your computer and use it in GitHub Desktop.
Save Imeguras/253f74d3caa327f8040433548d5d2c2f to your computer and use it in GitHub Desktop.
just a very very crude scrapper made for discord in order to circumvent not being able to @ people
/*//grab the innerHTML of the child of the elements with the class username-i5-wv-
//and console.log the value prepended by @
var usernames = [];
var username = document.getElementsByClassName('username-i5-wv-');
//for each username print the innerHTML of every child
for (var i = 0; i < username.length; i++) {
usernames.push('@' + username[i].children[0].innerHTML);// I Think its this... im horrible at JS
}
console.log(usernames.toString());
//I dont think it will work its too early for me to think...
*/
//NEW
var username = document.getElementsByClassName('wrapper-1VLyxH');
//get the atribute aria-label from username
var usernames = "";
for (var i = 0; i < username.length; i++) {
let foo="@"+username[i].getAttribute('aria-label');
//remove ', Online' from the end of foo and ", Do Not Disturb" and ", Idle"
if (foo.endsWith(', Online')) {
foo = foo.slice(0, -8);
}else if (foo.endsWith(', Do Not Disturb')) {
foo = foo.slice(0, -14);
}else if (foo.endsWith(', Idle')) {
foo = foo.slice(0, -5);
}
usernames+=" , "+foo;
}
console.log(usernames.toString());
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment