NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name GitHub Subdir File Downloader // @version 0.1 // @description Download files from GitHub with just single click // @author TheAnknown // @match https://github.com/* // @require http://code.jquery.com/jquery-3.2.1.min.js // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; var color = "#000"; $(document).ready(function(){ start(); getFiles(); $("#theAWidth").on("change", function(){ $("#theAMenu").css({ "width":$("#theAWidth").val() }); }); $("#wgetHeight").on("input", function(){ $("#linux").css({ "height":$("#wgetHeight").val() }); }); $("#darkmode").on("change", function(){ if($(this).is(":checked")){ color = "#fff"; $("#theAMenu").css({ "background":"rgba(0,0,0,.75)", "border":"3px solid #000", "color":"#fff" }); $("#theAMenu a").css({ "color":"#fff" }); } else { color = "#000"; $("#theAMenu").css({ "background":"rgba(150,150,150,0.4)", "border":"3px solid #000", "color":"#000" }); $("#theAMenu a").css({ "color":"#000" }); } }); }); function start(){ var menu = "<div id='theAMenu' style='position:fixed;top:0;left:0;background:rgba(150,150,150,0.4);border:3px solid #000;display:block;width:250px;z-index:9999;text-align:center;cursor:pointer'>"; menu += "<center><h3 style='background:#000;color:#fff;'>GitHub Subdir File Downloader</h3></center>"; menu += "<div id='files' style='overflow:scroll;height:250px;overflow-x:hidden;'><center><h1 style='background:#000;color:#fff;'>FILES</h1></center></div>"; menu += "<div id='linux' style='overflow:scroll;height:100px;overflow-x:hidden;'><center><h3 style='background:#000;color:#fff;'>WGET</h3></center><input type='range' id='wgetHeight' value='100' min='100' max='500' step='1'><p id='wget' style='padding: 0 .5em;'></p></div>"; menu += "<div id='settings'><center><h4 style='background:#000;color:#fff;'>Settings</h4></center><input type='range' id='theAWidth' value='250' min='250' max='1000' step='1'><br>Dark mode? <input type='checkbox' id='darkmode'></div>"; menu += "</div>"; var styles = "<style>"; styles += "#theAMenu a { display:block;padding:.2em 0;margin: 0 auto;transition: all ease-in-out .2s;text-decoration:none;color: #000; } #theAMenu a:hover { color:#000 !important; background:#fff;}"; styles += "</style>"; document.getElementsByTagName("body")[0].innerHTML += styles + menu; } function getFiles(){ var files = document.getElementsByClassName("js-navigation-open"); var s = ""; var links = ""; for(var i = 0; i < files.length; i++){ if(i > 9){ var filename = files[i].title; var link = files[i].href.split("github.com").join("raw.githubusercontent.com").split("/tree").join("").split("/blob").join(""); var current = $(files[i]).parent().parent().siblings()[0]; var isFolder = $($(current).children()[0]).attr("class") == "octicon octicon-file-directory"; if(!isFolder){ if(i == files.length - 1){ s += "wget " + link; } else { s += "wget " + link + " && "; } links += "<a href='" + link + "' download style='color:" + color + "'>" + filename + "</a>"; } } } $("#files").html(links); $("#wget").html(s); } var body = ""; setInterval(function(){ if(body != $("body").html()){ body = $("body").html(); getFiles(); } }, 1000); })();