Forum gallery downloader script

pushitplayit

New member
Approved
Download all the photos a user attached on their post. It will auto download all the photos and place it into a rar for you.

This script was originally made from a admin on thothub (rip). It was rebuilt to work on a similar forum to ours (S-E), so I'm sharing it here since it's fully compatible with this forum.

You need the Tampermonkey addon/extension. Create a new script and copy/paste the code.

Code:
// ==UserScript==
// @name         Forum Gallery Downloader
// @namespace    ThotDev
// @description  Download galleries from posts on forum.thothub.tv
// @version      1.1.1
// @icon         https://i.imgur.com/5xpgAny.jpg
// @license      WTFPL; http://www.wtfpl.net/txt/copying/
// @match        https://forum.sexy-egirls.com/*
// @match        https://nudostar.com/*
// @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 $this = $(this);

                    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 {
                            var title = $('h1.p-title-value').text().trim();
                            var postNumber = $this.closest('ul.message-attribution-opposite').find('li:last-child > a').text();
                            $text.text('Generating zip...');
                            zip.generateAsync({ type: 'blob' })
                                .then(function (blob) {
                                    $text.text('Download complete!');
                                    saveAs(blob, postNumber + ' ' + title + '.zip');
                                });

                        }
                    }
                    next();
                });
            }
        );
});
 

tyler_

Member
Approved
Some additions for the script above (!thx)
  • Download all from page
  • Fix download icon
  • Check if post has possible downloads, otherwise skip
JavaScript:
// ==UserScript==
// @name         Forum Gallery Downloader
// @namespace    ThotDev
// @description  Download galleries from posts on forum.thothub.tv
// @version      1.2
// @icon         https://i.imgur.com/5xpgAny.jpg
// @license      WTFPL; http://www.wtfpl.net/txt/copying/
// @match        https://forum.sexy-egirls.com/*
// @match        https://nudostar.com/*
// @match        https://forum.lewdweb.net/*
// @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="#" class="downloadSinglePost">↓ Download</a><li>');
                var $text = downloadLink.children('a');
                downloadLink.insertBefore($(this));
                downloadLink.click(function (e) {
                    e.preventDefault();

                    var $this = $(this);
                    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 current = 0,
                        total = urls.length,
                        zip = (zip === undefined) ? new JSZip() : zip;
                   collectDownloads($this,$text,zip,current,total,urls);
                });
            }
        );

    // download function
    function collectDownloads(loc,info,zip,current,total,urls) {
      //  check if downloads available
      if (total>0) {
        info.text('Downloading...');

                       if (current < total) {
                            info.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) {

                                    }
                                    collectDownloads(loc,info,zip,current,total,urls);
                                },
                                onerror: function (response) {
                                    collectDownloads(loc,info,zip,current,total,urls);
                                }
                            });
                        }
                        else {
                            var title = $('h1.p-title-value').text().trim();
                            var postNumber = loc.closest('ul.message-attribution-opposite').find('li:last-child > a').text();
                            info.text('Generating zip...');
                            zip.generateAsync({ type: 'blob' })
                                .then(function (blob) {
                                    info.text('Download complete!');
                                    saveAs(blob, postNumber + ' ' + title + '.zip');
                                });

                        }

      } else {
          info.text( (current==0 ? 'No Downloads!' : 'Downloads finished!') );
      }

    }

   // add 'download all' button
   var downloadAllLink = $('<a href="#" class="downloadAllFiles">↓ Download All</a>');
   $("div.buttonGroup").css({'display':'inline-flex','flex-wrap':'wrap','gap':'12px','align-items':'center','margin-right':'-12px'}).prepend(downloadAllLink);

   // download all files on page
   $(document).on("click",".downloadAllFiles",function(e){
       e.preventDefault();
       var urls = $('.lbContainer a.js-lbImage,.lbContainer-zoomer')
                     .map(function () { return $(this).is('[href]') ? $(this).attr('href') : $(this).data('src'); })
                     .get();

       var current = 0,
           total = urls.length,
           zip = (zip === undefined) ? new JSZip() : zip;

           collectDownloads($('.lbContainer'),downloadAllLink,zip,current,total,urls);
   });
});
 
Last edited:

FCPR311

Active member
Approved
Some additions for the script above (!thx)
  • Download all from page
  • Fix download icon
  • Check if post has possible downloads, otherwise skip
JavaScript:
// ==UserScript==
// @name         Forum Gallery Downloader
// @namespace    ThotDev
// @description  Download galleries from posts on forum.thothub.tv
// @version      1.2
// @icon         https://i.imgur.com/5xpgAny.jpg
// @license      WTFPL; http://www.wtfpl.net/txt/copying/
// @match        https://forum.sexy-egirls.com/*
// @match        https://nudostar.com/*
// @match        https://forum.lewdweb.net/*
// @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="#" class="downloadSinglePost">↓ Download</a><li>');
                var $text = downloadLink.children('a');
                downloadLink.insertBefore($(this));
                downloadLink.click(function (e) {
                    e.preventDefault();

                    var $this = $(this);
                    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 current = 0,
                        total = urls.length,
                        zip = (zip === undefined) ? new JSZip() : zip;
                   collectDownloads($this,$text,zip,current,total,urls);
                });
            }
        );

    // download function
    function collectDownloads(loc,info,zip,current,total,urls) {
      //  check if downloads available
      if (total>0) {
        info.text('Downloading...');

                       if (current < total) {
                            info.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) {

                                    }
                                    collectDownloads(loc,info,zip,current,total,urls);
                                },
                                onerror: function (response) {
                                    collectDownloads(loc,info,zip,current,total,urls);
                                }
                            });
                        }
                        else {
                            var title = $('h1.p-title-value').text().trim();
                            var postNumber = loc.closest('ul.message-attribution-opposite').find('li:last-child > a').text();
                            info.text('Generating zip...');
                            zip.generateAsync({ type: 'blob' })
                                .then(function (blob) {
                                    info.text('Download complete!');
                                    saveAs(blob, postNumber + ' ' + title + '.zip');
                                });

                        }

      } else {
          info.text( (current==0 ? 'No Downloads!' : 'Downloads finished!') );
      }

    }

   // add 'download all' button
   var downloadAllLink = $('<a href="#" class="downloadAllFiles">↓ Download All</a>');
   $("div.buttonGroup").css({'display':'inline-flex','flex-wrap':'wrap','gap':'12px','align-items':'center','margin-right':'-12px'}).prepend(downloadAllLink);

   // download all files on page
   $(document).on("click",".downloadAllFiles",function(e){
       e.preventDefault();
       var urls = $('.lbContainer a.js-lbImage,.lbContainer-zoomer')
                     .map(function () { return $(this).is('[href]') ? $(this).attr('href') : $(this).data('src'); })
                     .get();

       var current = 0,
           total = urls.length,
           zip = (zip === undefined) ? new JSZip() : zip;

           collectDownloads($('.lbContainer'),downloadAllLink,zip,current,total,urls);
   });
});
});
I got it to work. Thanks!
 
Last edited:

nicefooly

New member
I got it to work. Thanks!
anything special to get this to work? im on firefox and have tried pasting the code into tampermonkey and violentmonkey. when im on the forum both extensions icons seem to recognize theres a script for this site, but i dont see any sort of download button or anything in the post?
 

nicefooly

New member
@nicefooly quickest way to see the download links: search for "download" on site and you will see them. upper right corner of each reply ;)

err yeah thats my point, i added the code into tampermonkey and dont see any sort of download button on any post. i see bookmark post, i see the post number, i see the like and reply buttons to posts, etc...
 

nikon180

Active member
Approved
Some additions for the script above (!thx)
  • Download all from page
  • Fix download icon
  • Check if post has possible downloads, otherwise skip
JavaScript:
// ==UserScript==
// @name         Forum Gallery Downloader
// @namespace    ThotDev
// @description  Download galleries from posts on forum.thothub.tv
// @version      1.2
// @icon         https://i.imgur.com/5xpgAny.jpg
// @license      WTFPL; http://www.wtfpl.net/txt/copying/
// @match        https://forum.sexy-egirls.com/*
// @match        https://nudostar.com/*
// @match        https://forum.lewdweb.net/*
// @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="#" class="downloadSinglePost">↓ Download</a><li>');
                var $text = downloadLink.children('a');
                downloadLink.insertBefore($(this));
                downloadLink.click(function (e) {
                    e.preventDefault();

                    var $this = $(this);
                    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 current = 0,
                        total = urls.length,
                        zip = (zip === undefined) ? new JSZip() : zip;
                   collectDownloads($this,$text,zip,current,total,urls);
                });
            }
        );

    // download function
    function collectDownloads(loc,info,zip,current,total,urls) {
      //  check if downloads available
      if (total>0) {
        info.text('Downloading...');

                       if (current < total) {
                            info.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) {

                                    }
                                    collectDownloads(loc,info,zip,current,total,urls);
                                },
                                onerror: function (response) {
                                    collectDownloads(loc,info,zip,current,total,urls);
                                }
                            });
                        }
                        else {
                            var title = $('h1.p-title-value').text().trim();
                            var postNumber = loc.closest('ul.message-attribution-opposite').find('li:last-child > a').text();
                            info.text('Generating zip...');
                            zip.generateAsync({ type: 'blob' })
                                .then(function (blob) {
                                    info.text('Download complete!');
                                    saveAs(blob, postNumber + ' ' + title + '.zip');
                                });

                        }

      } else {
          info.text( (current==0 ? 'No Downloads!' : 'Downloads finished!') );
      }

    }

   // add 'download all' button
   var downloadAllLink = $('<a href="#" class="downloadAllFiles">↓ Download All</a>');
   $("div.buttonGroup").css({'display':'inline-flex','flex-wrap':'wrap','gap':'12px','align-items':'center','margin-right':'-12px'}).prepend(downloadAllLink);

   // download all files on page
   $(document).on("click",".downloadAllFiles",function(e){
       e.preventDefault();
       var urls = $('.lbContainer a.js-lbImage,.lbContainer-zoomer')
                     .map(function () { return $(this).is('[href]') ? $(this).attr('href') : $(this).data('src'); })
                     .get();

       var current = 0,
           total = urls.length,
           zip = (zip === undefined) ? new JSZip() : zip;

           collectDownloads($('.lbContainer'),downloadAllLink,zip,current,total,urls);
   });
});
});
actually you have an extra set of }); at the end.
 

FlyxAskani

New member
Hey ! When I press "Download", the button now changes to "No downloads" and nothing happens... Any idea on how to fix this ?
 

Mugge

New member
To everyone having trouble for this to work. Its probably because you dont know where the download button is lol... Its on the page beside "Watch" when you enter a thread. NOT in the bar.
 

hothot22

New member
Hi, i just noticed it doesn't grab everything. As an example here, the vids are not downloaded.
For example here:

I'm sadly no savy enough with the js stuff
 

xecec85860

New member
Some additions for the script above (!thx)
  • Download all from page
  • Fix download icon
  • Check if post has possible downloads, otherwise skip
This script does not handle files with same names. I took the liberty of including a simple counter at the beginning of each file to ensure that no two files have same names even if they would be uploaded with matching names. Everything else is identical.


JavaScript:
// ==UserScript==
// @name         Forum Gallery Downloader
// @namespace    ThotDev
// @description  Download galleries from posts on forum.thothub.tv
// @version      1.2
// @icon         https://i.imgur.com/5xpgAny.jpg
// @license      WTFPL; http://www.wtfpl.net/txt/copying/
// @match        https://forum.sexy-egirls.com/*
// @match        https://nudostar.com/*
// @match        https://forum.lewdweb.net/*
// @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="#" class="downloadSinglePost">↓ Download</a><li>');
                var $text = downloadLink.children('a');
                downloadLink.insertBefore($(this));
                downloadLink.click(function (e) {
                    e.preventDefault();

                    var $this = $(this);
                    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 current = 0,
                        total = urls.length,
                        zip = (zip === undefined) ? new JSZip() : zip;
                   collectDownloads($this,$text,zip,current,total,urls);
                });
            }
        );

    // download function
    function collectDownloads(loc,info,zip,current,total,urls) {
      //  check if downloads available
      if (total>0) {
        info.text('Downloading...');

                       if (current < total) {
                            info.text('Downloading ' + (current+1) + '/' + total);

                            GM.xmlHttpRequest({
                                method: 'GET',
                                url: urls[current++],
                                responseType: 'arraybuffer',
                                onload: function (response) {
                                    try {
                                        debugger;
                                        var name = current + "-" + response.responseHeaders.match(/^content-disposition.+(?:filename=)(.+)$/mi)[1].replace(/\"/g, '');
                                        var data = response.response;
                                        zip.file(name, data);
                                    }
                                    catch (err) {

                                    }
                                    collectDownloads(loc,info,zip,current,total,urls);
                                },
                                onerror: function (response) {
                                    collectDownloads(loc,info,zip,current,total,urls);
                                }
                            });
                        }
                        else {
                            var title = $('h1.p-title-value').text().trim();
                            var postNumber = loc.closest('ul.message-attribution-opposite').find('li:last-child > a').text();
                            info.text('Generating zip...');
                            zip.generateAsync({ type: 'blob' })
                                .then(function (blob) {
                                    info.text('Download complete!');
                                    saveAs(blob, postNumber + ' ' + title + '.zip');
                                });

                        }

      } else {
          info.text( (current==0 ? 'No Downloads!' : 'Downloads finished!') );
      }

    }

   // add 'download all' button
   var downloadAllLink = $('<a href="#" class="downloadAllFiles">↓ Download All</a>');
   $("div.buttonGroup").css({'display':'inline-flex','flex-wrap':'wrap','gap':'12px','align-items':'center','margin-right':'-12px'}).prepend(downloadAllLink);

   // download all files on page
   $(document).on("click",".downloadAllFiles",function(e){
       e.preventDefault();
       var urls = $('.lbContainer a.js-lbImage,.lbContainer-zoomer')
                     .map(function () { return $(this).is('[href]') ? $(this).attr('href') : $(this).data('src'); })
                     .get();

       var current = 0,
           total = urls.length,
           zip = (zip === undefined) ? new JSZip() : zip;

           collectDownloads($('.lbContainer'),downloadAllLink,zip,current,total,urls);
   });
});
 
Top