Last active
September 13, 2024 14:36
-
-
Save lucasquin/9cf192b3aa7455cbc2166f4949354cc5 to your computer and use it in GitHub Desktop.
List the users of a Discord server
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 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