Derpibooru - Download All

Adds a download button that lets you download all images in a gallery.

29.09.2014 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Derpibooru - Download All
// @namespace   Selbi
// @include     http*://*derpiboo.ru/*
// @include     http*://*derpibooru.org/*
// @version     1.1
// @description Adds a download button that lets you download all images in a gallery.
// ==/UserScript==

const INTERVAL_TIME = 1000;
const URL_NAME = location.protocol + "//" + location.hostname + location.pathname;

$(".metabar:eq(0)").append('<a href="javascript:void()" id="GetAllLinks">Get All Links</a> <a href="javascript:void()" id="StartDownload" style="display:none">Start Download!</a>');

var pagecount = (/\d+/).exec($(".last a").attr("href"));
if (pagecount == null) pagecount = 1;
var linksarr = [];
var i = 0;

$("#GetAllLinks").click(function(){
	$(this).attr('style', 'pointer-events:none; cursor:default;').html("Grabbings Links... (0)");
	for (var int=1; int<=pagecount; int++){
		$.ajax({
			async: false,
			type: 'GET',
			url: URL_NAME + "?page=" + int,
			success: function(data){
				$(".image_container", data).each(function(){
					linksarr.push($(this).attr("data-download-uri"));					
					$("#GetAllLinks").html("Grabbings Links... (" + linksarr.length + ")");
				});
			}
		});
	}
	$("#GetAllLinks").hide();
	$("#StartDownload").html("Start Download! (0/" + linksarr.length + ") [Warning: Opens a new tab for each image!]").show();
});

function downloadImage(){
	window.open(linksarr[i], '_blank');
	// GM_openInTab(linksarr[i]);

	$("#StartDownload").html("Downloading... (" + (i+1) + "/" + linksarr.length + ")");
	i++;
	if (i < (linksarr.length)) {
		setTimeout(function(){downloadImage()}, INTERVAL_TIME);
	} else {
		$("#StartDownload").attr('style', 'pointer-events:none; cursor:default;').html("Finished Download! (" + i + "/" + linksarr.length + ")");
	}
}

$("#StartDownload").click(function(){
	$(this).html("Downloading... (0/" + linksarr.length + ")");
	setTimeout(function(){downloadImage()}, INTERVAL_TIME);
	var timer = setInterval();
});