Skip to content

Instantly share code, notes, and snippets.

@calvinthefreak
Created September 17, 2019 17:20
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 calvinthefreak/e26957b590c8d08527cf5caccb349a50 to your computer and use it in GitHub Desktop.
Save calvinthefreak/e26957b590c8d08527cf5caccb349a50 to your computer and use it in GitHub Desktop.
Quick and dirty Discord attachement downloader (written in bash and javascript)
#!/bin/bash
#
#GET YOUR URLS BY RUNNING THIS IN THE CONSOLE OF YOUR BROWSER THEN OPEN LINUX CONSOLE, `nano list.list` --> Paste content of link got in browser and let this script run with bash run.sh
: '
#Paste this to your Browser:
localarray = [];
attachmentscollectortimer = setInterval(attachmentscollector, 100);
function attachmentscollector() {
var images = document.getElementsByTagName("a");
for (var i = document.getElementsByTagName("a").length - 1; i >= 0; i--) {
var element = document.getElementsByTagName("a")[i];
if(element.href.includes("discordapp.net/attachments/") || element.href.includes("discordapp.com/attachments/"))
{
if(!localarray.includes(element.href.split("?")[0]))
{
localarray.push(element.href.split("?")[0]);
//console.log(element.href.split("?")[0]);
}
}
}
}
var textFile = null,
makeTextFile = function (text) {
var data = new Blob([text], {type: "text/plain"});
if (textFile !== null) {
window.URL.revokeObjectURL(textFile);
}
textFile = window.URL.createObjectURL(data);
return textFile;
};
function getdl(attachmentscollectortimer) {
console.clear();
console.log("Copy and paste this here in a new tab:")
console.log(makeTextFile(localarray.splice(",").join("\r\n")));
}
console.clear();
console.log("enter getdl(); to get the downloadlink when you have finished scrolling the page to the point where all wanted images are loaded!");
'
mkdir img
input="list.list"
cat $input | awk '{print $1;}' > "$input.file"
while IFS= read -r Fs
do
wget --user-agent="Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0" "$Fs"
F=$(basename "$Fs")
mv "$F" "img/$(md5sum "$F" | cut -d' ' -f1).${F##*.}";
done < "$input.file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment