Doujins Loader

Get all of the urls from a page on Doujins.com

// ==UserScript==
// @name         Doujins Loader
// @description  Get all of the urls from a page on Doujins.com
// @namespace    https://sleazyfork.org/en/users/182876-belphegor
// @version      1
// @author       https://sleazyfork.org/en/users/182876-belphegor
// @match        https://doujins.com/*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.onload = function () {
        var imgDoujin = document.querySelector("img.doujin")
        var urlList = []

        function allLoadedCallback () {
            var counter = 0
            window.doujinUrls = urlList
            window.doujinWGET = urlList.map(function (url) {
                counter++
                return `wget "${url}" -O ${counter}.jpg`
            }).join('\n')
            console.log(window.doujinWGET)
        }

        if (imgDoujin) {
            var imgDoujinNext = imgDoujin
            var iv = setInterval(function () {
                urlList.push(imgDoujinNext.dataset.file)
                if (imgDoujinNext.nextElementSibling && imgDoujinNext.nextElementSibling.dataset.file) {
                    imgDoujinNext = imgDoujinNext.nextElementSibling
                    console.log('loading next')
                } else {
                    clearInterval(iv);
                    allLoadedCallback();
                }
            }, 600)
        }
    }
})();