pic.inmac links handler

Allow to get links for all uploaded links in one click

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         pic.inmac links handler
// @version      0.2.1
// @description  Allow to get links for all uploaded links in one click
// @author       DevMan, (StarCom - Russian Localise)
// @match        http*://pic.inmac.org/*
// @include      http*://pic.inmac.org/*
// @grant        none
// @namespace	 https://greasyfork.org/users/7303
// @require		 https://code.jquery.com/jquery-2.1.1.min.js
// ==/UserScript==

$('.nav').append('<li><a href="#" id="do-copy">Скопировать Все</a></li>');
$('#do-copy').click(function(){doCopy();});

function getLinks() {
	var links = $('input#show_url');
    var result = {
        direct: [],
        th: [],
        img: []
    }
    for( var i = 0, size = links.length; i < size; i+=3 ) {
        result.direct.push( $(links[i]).val() );
        result.th.push( $(links[i+1]).val() );
        result.img.push( $(links[i+2]).val() );
    }
    return result;
}

function doCopy() {
    var links = getLinks();
    if( links.direct.length == 0 ) {
        return;
    }
    
    $('#links').remove();
    $('.navbar').after('<div class="container" id="links" style="white-space: pre-line;"></div>');
    var el = $('#links');
    el.append('<h5>Основная ссылка:</h5>');
    for( var i in links.direct ) {
        el.append( links.direct[i] + '<br>' );
    }
    el.append('<h5>Уменьшенная ссылка :</h5>');
    for( var i in links.th ) {
        el.append( links.th[i] + ' ' );
    }
    el.append('<h5>Ссылка для форума:</h5>');
    for( var i in links.img ) {
        el.append( links.img[i] + ' ' );
    }
    $( window ).scrollTop( 0 );
}