Skip to content

Instantly share code, notes, and snippets.

@Hans5958
Last active May 22, 2021 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hans5958/92e45fa046ed7198137ed149a342cf85 to your computer and use it in GitHub Desktop.
Save Hans5958/92e45fa046ed7198137ed149a342cf85 to your computer and use it in GitHub Desktop.
Searches links on Discord. For ripping pictures/attachments.
var links = []
var messages = document.getElementsByClassName("messages")[0]
var startLinks
var endLinks
function check() {
startLinks = links.length
array = document.getElementsByTagName("a")
for (i = 0; i < array.length; i++) {
if (links.includes(array[i].href) == false) {
console.log(array[i].href)
links.push(array[i].href)
}
}
endLinks = links.length - startLinks
}
function loadMore() {
a = document.getElementsByTagName("button")
for (i = 0; i < a.length; i++) {
if (a[i].innerHTML == "Load more messages") {a[i].click()}
}
}
function upAway() {
loadMore();
if(messages.scrollTop == 0) {
if (document.getElementsByClassName("base-34jWEe").length == 0) {
window.setTimeout(upAway, 1000);
} else {
console.log("[ACTIVITY] Top found. End of loop.")
}
} else {
console.log("[ACTIVITY] Finding links...")
check();
console.log("[ACTIVITY] Found " + endLinks + " new unique links.")
console.log("[ACTIVITY] Links found: " + links.length)
messages.scrollTop = 0
window.setTimeout(upAway, 1000);
}
}
upAway();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment