hitomi.la Download Tweaker

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

As of 2019-08-24. See the latest version.

// ==UserScript==
// @name         hitomi.la Download Tweaker
// @description  Tweaks the download script so that filenames follow %03d format
// @namespace    redturtle
// @author       redturlte
// @version      1.5
// @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
        });

        $.ajax({
            url: '//' + domain + '/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((i + 1 < 10 ? '000' + (i + 1).toString() : i + 1 < 100 ? '00' + (i + 1).toString() : i + 1 < 1000 ? '0' + (i + 1).toString() : (i + 1).toString()) + image.name.substring(image.name.length - 4, image.name.length));
                });
                zip = new JSZip();
                currently_downloading_url_index = 0;
                if (galleryname) {
                    galleryname_to_download = galleryname;
                }
                download_next_image();
            }
        });
    };
});