hitomi.la Download Tweaker

Tweaks the download script so that filenames follow %03d format

// ==UserScript==
// @name         hitomi.la Download Tweaker
// @description  Tweaks the download script so that filenames follow %03d format
// @namespace    onlyforfap
// @author       onlyforfap
// @version      1.0
// @match        https://hitomi.la/galleries/*
// @noframes
// @connect      self
// @run-at       document-idle
// ==/UserScript==

$(document).ready(function () {
    download_gallery = function (galleryid, galleryname) {
        $("#dl-button").hide();
        var progressbar = $("#progressbar");
        progressbar.show();
        progressbar.progressbar({
            value: false
        });
        var pad = '000';

        $.ajax({
            url: '/galleries/' + galleryid + '.js',
            success: function () {
                urls_to_download = [];
                image_names_to_download = [];
                $.each(galleryinfo, function (i, image) {
                    var url = '//a.hitomi.la/galleries/' + galleryid + '/' + image.name;
                    urls_to_download.push(url_from_url(url));
                    image_names_to_download.push(pad.substr(0, 3 - (i + 1).toString().length) + (i + 1) + image.name.substr(image.name.length - 4));
                });
                zip = new JSZip();
                currently_downloading_url_index = 0;
                if (galleryname) {
                    galleryname_to_download = galleryname;
                }
                download_next_image();
            }
        });
    };
});