Created
November 23, 2013 13:00
-
-
Save roooodcastro/7614346 to your computer and use it in GitHub Desktop.
Fileswap script to download files in batch. This javascript code will iterate over an URL list to download each file in it, with an interval of 15 seconds between each link (I consider this a safe interval, as a smaller one might open too many pages at the same time, and eventually the browser won't be able to respond to the new requests, breaki…
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
// Example url list | |
list = [ | |
"http://www.fileswap.com/dl/4VwkwcWNM/", | |
"http://www.fileswap.com/dl/SFIXwosILI/", | |
"http://www.fileswap.com/dl/KRatrq4R/", | |
"http://www.fileswap.com/dl/j5FxFWGTwi/", | |
"http://www.fileswap.com/dl/jbBYBjHOOk/", | |
] | |
download = function(url) { | |
// Opens a new window with the download page | |
w1 = window.open(url); | |
setTimeout(function() { | |
link = w1.document.getElementById("share_index_dlslowbutton"); | |
if (link) { | |
// Opens a new window with the direct link to the download | |
w2 = window.open(link.href); | |
} | |
// We already got the direct link, we don't need this window anymore | |
w1.close(); | |
setTimeout(function() { | |
if (w2) { | |
// The download should just start, after a few seconds we can just close the window | |
w2.close(); | |
} | |
}, 5000); | |
}, 10000); | |
} | |
// This function will iterate over the urls until all links have been downloaded, with an interval of 15s between each url | |
// The first call should be: "loop(0)", or another index if you don't want to start from the beginning | |
loop = function(index) { | |
if (index < list.length) { | |
download(list[index]); | |
setTimeout(function() { | |
loop(index + 1); | |
}, 15000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment