Derpibooru - Download All

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

Stan na 29-09-2014. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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();
});