KMImgDLer

Auto-download all pics

2020-07-29 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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