Hello all!
I modified the code that was made for TH to download attached images in threads. The same requirements that made it work there, are required to make it work here (Chrome/Firefox and Tampermonkey/Greasemonkey/whatever).
I claim no credit for this original code and I offer no support for it. I just modified it to make it work for me and figured others here could benefit from it too!
Have fun and may we always remember TH!
I modified the code that was made for TH to download attached images in threads. The same requirements that made it work there, are required to make it work here (Chrome/Firefox and Tampermonkey/Greasemonkey/whatever).
I claim no credit for this original code and I offer no support for it. I just modified it to make it work for me and figured others here could benefit from it too!
Have fun and may we always remember TH!
Code:
// ==UserScript==
// @name Leakednudes Forum Gallery Downloader - Aug, 15 2020
// @namespace None
// @description Download galleries from posts on leakednudes.com
// @version 1.1.2
// @icon https://i.imgur.com/5xpgAny.jpg
// @license WTFPL; http://www.wtfpl.net/txt/copying/
// @match https://leaknudes.com/*
// @match https://
// @require https://code.jquery.com/jquery-3.3.1.min.js
// @require https://unpkg.com/[email protected]/dist/jszip.min.js
// @require https://unpkg.com/[email protected]/dist/FileSaver.min.js
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js?v=a834d46
// @noframes
// @connect self
// @run-at document-start
// @grant GM.xmlHttpRequest
// @grant GM_xmlhttpRequest
// ==/UserScript==
/* globals jQuery JSZip saveAs */
jQuery(function ($) {
$('.message-attribution-opposite')
.map(function () { return $(this).children('li:first'); })
.each(function () {
var downloadLink = $('<li><a href="#">⬇️ Download</a><li>');
var $text = downloadLink.children('a');
downloadLink.insertBefore($(this));
downloadLink.click(function (e) {
e.preventDefault();
var urls = $(this)
.parents('.message-main')
.first()
.find('a.js-lbImage,.lbContainer-zoomer')
.map(function () { return $(this).is('[href]') ? $(this).attr('href') : $(this).data('src'); })
.get();
var zip = new JSZip(),
current = 0,
total = urls.length;
$text.text('Downloading...');
function next () {
if (current < total) {
$text.text('Downloading ' + (current+1) + '/' + total);
GM.xmlHttpRequest({
method: 'GET',
url: urls[current++],
responseType: 'arraybuffer',
onload: function (response) {
try {
debugger;
var name = response.responseHeaders.match(/^content-disposition.+(?:filename=)(.+)$/mi)[1].replace(/\"/g, '');
var data = response.response;
zip.file(name, data);
}
catch (err) {
}
next();
},
onerror: function (response) {
next();
}
});
}
else {
const fileName = $(".p-title-value")[0].textContent
const timeStamp = $.now()
$text.text('Generating zip...');
zip.generateAsync({ type: 'blob' })
.then(function (blob) {
$text.text('Download complete!');
saveAs(blob, `${fileName}-${timeStamp}.zip`);
});
}
}
next();
});
}
);
});