KMImgDLer

Auto-download all pics

Από την 29/07/2020. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name     KMImgDLer
// @version  2.0
// @grant    GM_addStyle
// @grant    GM_download
// @include https://www.kaufmich.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @require https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js
// @namespace https://greasyfork.org/users/290665
// @description Auto-download all pics
// ==/UserScript==


$("head").append (
    '<link '
  + 'href="//ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.min.css" '
  + 'rel="stylesheet" type="text/css">'
);
addStyle();
var myVersion = GM_info.script.version;
var username = document.baseURI.replace(/.*\.com\//,'').replace(/#$/,'');

function artistname() {
    var name = $('h2.user-name').clone().children().remove().end().text();
    name = name.replace(/(^\s+|\s+$)/g,'');
    return name;
}
$(function() {
    var name = artistname();
    if (name.length) {
        $('.content:first').css('position','relative');
        var myspace = $('<div id="KMImgDLer"></div>').appendTo('.content:first');
        $('<div class="KMImgDLerLogo">powered by KMImgDLer '+myVersion+'</div>').appendTo(myspace);
        $('<a class="kmButton" href="#">Download all photos</a>').on('click', startDLALL).appendTo(myspace);
        var searchButton = $('<a class="kmButton" target="_blank">search LH</a>').appendTo(myspace);
        var searchQuery = (username.toLowerCase() == name.toLowerCase()) ? `"${name}"` : `("${username}" OR "${name}")`;
        $(searchButton).attr('href',`https://www.google.de/search?as_sitesearch=lusthaus.cc&q=${searchQuery}`);
    }
});

function startDLALL() {
    var downloadlist = [];
    $(preload_images).each(function() {
        var link = $(this).attr('src');
        if (1) {
            downloadlist.push(link);
            console.log(link);
        }
    });
    var name = artistname();
    var path = name;
    if (name.toLowerCase() != username.toLowerCase()) path += `,${username}`
    dlAll(path,downloadlist.filter( function (value, index, self) {
        return self.indexOf(value) === index;
    } ));
}

function dlAll(path,downloadlist) {

    var dialog = $('<div id="dialog"></div>').dialog({
        title: 'Download to '+path+' ...',
        modal: true,
        width: 600,
        buttons: {
            Ok: function() {
                $( this ).dialog( "close" );
            }
        }
    });

    for (let URL of downloadlist) {
        var name = URL.replace(/.*\//,'');
        var file = path.replace(/[^\w-\(\)]/g,'')+'/'+name;
        URL = URL.replace(/^\/\//,'https://');
        var line = $('<div class="RLDL" data-name="'+name+'">'+name+'</div>\n').appendTo(dialog);

        console.log([URL,file]);

        (function(url,filepath,filename,linediv) {
            var dl = GM_download({
                url: url,
                name: filepath,
                saveAs: false,
                onerror: function(){
                    $(linediv).append('<span class="download_error">ERROR: '+err.error+'<br>'+err.details+'</span>');
                },
                onload: function() {
                    $(linediv).append('<span class="download_ok">✓</span>');
                }
            });
        })(URL,file,name,line);

    }
}

function addStyle() {
    GM_addStyle(`
.download_error {
    color: white;
    background-color: #880010;
    padding: 1px 4px;
    border-radius: 2px;
    margin: 0px 4px;
}

.download_ok {
    color: white;
    background-color: #10a020;
    padding: 1px 4px;
    border-radius: 2px;
    margin: 0px 4px;
}
#KMImgDLer {
	position: absolute;
	top: 12px;
	right: 236px;
	overflow: visible;
	z-index: 10000;
    text-align:right;
}
#KMImgDLer .kmButton {
    margin-left:4px;
}
.KMImgDLerLogo {
    position: absolute;
    color: #e1025d;
    font-size: 9px;
    top: -15px;
    right:0px;
}
`);
}