7KiLL / Spaces GetThreadListBB

// ==UserScript==
// @name        Spaces GetThreadListBB
// @namespace   spaces
// @description Taking list of forum threads on spaces.ru
// @include     http://spaces.ru/forums/?f=*
// @include     https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @version     0.1
// @copyright 2015 7KiLL (http://spaces.ru/mysite/?name=7kill)
// ==/UserScript==


       $('<button id="show_btn">Show</button>').appendTo($('.sep_bl').eq(0));
       $('<button id="hide">Hide</button>').appendTo($('.sep_bl').eq(0)).hide();
       $('<textarea id="resul"></textarea>').prependTo("body");
       $('#resul').hide();


//Show
        $('#show_btn').click(function() {
        $('#resul').show();
        $('#resul').css('overflow', 'auto');
        $('#resul').css('left', '60%');
        $('#resul').css('width', '40%');
        $('#resul').css('height', '100%');
        $('#resul').css('position', 'fixed');
        $(this).hide();
        $('#hide').show();
          $('#get_btn').fadeIn('slow');
          $('#clear_btn').fadeIn('slow');
    });

//Hide
        $(document).on('click','#hide', function(){
        $(this).hide();
          $('#resul').hide();
          $('#show_btn').show();
          $('#get_btn').fadeOut('slow');
          $('#clear_btn').fadeOut('slow');
});

$('<button id="clear_btn">Clear</button>').appendTo($('.sep_bl').eq(0)).hide();
   $('#clear_btn').click(function() {
   $('#resul').val('');

});

$('<button id="get_btn">GET</button>').appendTo($('.sep_bl').eq(0)).hide();
$('<button id="next_btn">Next</button>').appendTo($('.sep_bl').eq(0)).hide();


    $('#get_btn').click(function() {
        var pages = $('.pgn__counter.pgn__range.pgn__link_hover').text().split(' из ');
        var threads = $('.light_border_bottom.t-bg3').length;

        for(i=0; i<threads; i++) {
            var threadName = ($('.t-strong_item.t-link_item_hover').eq(i).text());
            var threadLink = ($('.t-block_item.stnd_padd.t-link_no_underline_block').eq(i).attr('href'));
            var arr = threadLink.split('&');
            var readyLink = 'http://spaces.ru/forums/?';
            readyLink += arr[1]

            var res = ('[url=' + readyLink + ']' + threadName + '[/url]');
            $('#resul').val($('#resul').val() + res + "\n");

        }
    });
/*
    $('#next_btn').click(function() {
        pages = $('.pgn__counter.pgn__range.pgn__link_hover').text().split(' из ');
        curpage = Number(pages[0])+1;
        $('#main').load('http://spaces.ru/forums/?f=48&tp=' + curpage + ' #main');
    });
*/

$('<button type="button" style="left:20px;" id="sel_all_btn">Select All</button>').appendTo($('.list_item').eq(2));
$('<button type="button" style="left:20px;" id="unsel_all_btn">Unselect All</button>').appendTo($('.list_item').eq(2)).hide();
var show_hide = 0;
$('#sel_all_btn').click(function() {
    var com_count = $('.list_item.oh').length;
    for(i = 0; i < com_count; i++)   {
        $('.oh>input:checkbox').eq(i).prop('checked', true);
        $(this).hide();
        $('#unsel_all_btn').show();
    }  
});

$('#unsel_all_btn').click(function() {
    var com_count = $('.list_item.oh').length;
    for(i = 0; i < com_count; i++)   {
        $('.oh>input:checkbox').eq(i).prop('checked', false);
        $(this).hide();
        $('#sel_all_btn').show();
    }
});