GitHub Easter-Egg – A Download List!

An easier files-downloading from GitHub.

Ok.. Not really an official easter-egg,
but still a nice feature to have..

It adds a buttons,
to download a text-file, with the files in the current “folder tree”,
not just names, but direct-download-links,

You can feed the list directly to Aria2C (with --input-file="list.txt" or wGet (with wget -i "list.txt" or with parallel (cygwin/linux): cat list.txt | parallel --gnu "wget {}")

Here is the JavaScript code you need to run on the page.

//  div.file-wrap a[href*="/blob/"]

//  div.file-wrap a[href*="/blob/"]

(function(old_button){  //remove old_button if exist
  if(null === old_button) return;
}(document.querySelector('[id="file_list_button"]'))) =;
var TEMPLATE    = '<a id="file_list_button" href="data:text/plain;charset:UTF-8;base64,##HREF##" title="##LINES## URLs, In A ##SIZE##KB Text File (Compatible w/ wGet/Aria2c)." class="btn" style="padding:2pt 10pt 2pt 10pt; margin:5pt 0 5pt 0; opacity:.5;" download="list.txt" charset="UTF-8">File-List</a>'
   ,placeholder = document.querySelector('div.file-wrap')
   ,target      = document.createElement("div")

list = document.querySelectorAll('div.file-wrap a[href*="/blob/"]')
                      return element.href
                                    .replace("", "")
                                    .replace("/blob/", "/")

//remove double-links.
list = Object.keys(
         list.reduce(function(carry, current){
           current = encodeURIComponent(current);
           carry[current] = 1;
           return carry;
       ).map(function(s){ return decodeURIComponent(s); });

lines = list.length;
list = list.join("\n");   //.join(/Windows/i.test(self.navigator.userAgent) ? "\r\n" : "\n") //variation to support Windows' EOL.
list = btoa(list);
size = list.length * 0.738; //estimated difference between real-length to BASE64-length.
size = (size).toFixed(2);

target.innerHTML = TEMPLATE.replace("##HREF##",  list)
                           .replace("##SIZE##",  size)
                           .replace("##LINES##", lines)
target = target.querySelector("a");

placeholder.parentElement.insertBefore(target, placeholder);

Just if really needed…
there is a line commented-out, to include a “\r\n” at the end-of of the lists-lines,
this will make the file readable with Windows’ notepad.
(but will break wget and aria2c… so don’t..)

You can download it as a Chrome-extension too:

Note that it will NOT play nice with the dynamic JS-navigation,
used to browse through folders (type of AJAX or SPF-like content-loader).
If you don’t care about dynamic-loading, you might as-well also install history-api-disabler, it will make GitHub and various other websites to fallback into standard loading the full pages, which also make the GitHub-Download-List work fine…