Skip to content

Instantly share code, notes, and snippets.

@lucasquin
Last active September 13, 2024 14:36
Show Gist options
  • Save lucasquin/9cf192b3aa7455cbc2166f4949354cc5 to your computer and use it in GitHub Desktop.
Save lucasquin/9cf192b3aa7455cbc2166f4949354cc5 to your computer and use it in GitHub Desktop.
List the users of a Discord server
function extractAndProcessNames(xpath) {
const results = new Set();
const xpathResult = document.evaluate(
xpath,
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (let i = 0; i < xpathResult.snapshotLength; i++) {
const name = xpathResult.snapshotItem(i).textContent.trim();
if (name && !name.startsWith('@')) {
results.add(name);
}
}
return Array.from(results);
}
// Usage
const xpath = `//span[contains(@class, 'desaturateUserColors')]/text()`;
const filteredNames = extractAndProcessNames(xpath);
console.log(filteredNames);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment