torrent9

enhance torrent9 / t411

As of 2018-01-27. See the latest version.

// ==UserScript==
// @name        torrent9
// @namespace   cpasbien
// @include     http://www.torrent9.*/*
// @include     https://www.torrent9.*/*
// @description enhance torrent9 / t411
// @version     1.4
// @grant       none
// ==/UserScript==

$('.gauche').hide();

$('html > head').append($([
    '<style>',
    ' .ligne0,.ligne1 {',
    '  width: 378px;',
    '  display: block;',
    '  float: left;',
    '}',
    '.titre {',
    '    width:240px;',
    '    background:transparent;',
    '    text-indent:0px;',
    '    padding:3px;',
    '    font-size:medium;',
    '}',
    '.dwnThumb {',
    '    float:left;',
    '    height:70px;',
    '}',
    '.dwnThumb img {',
    '    border:1px solid #9F9F9F;',
    '    -moz-border-radius:5px;',
    '    -webkit-border-radius:5px;',
    '    border-radius:5px;',
    '}',
    '.datas {',
    '    width:75px;',
    '    float:right;',
    '}',
    '.txtQuality {',
    '    color:orange;',
    '    font-size:10px;',
    '}',
    '.txtYear {',
    '    color:red;',
    '    font-size:10px;',
    '}',
    '.txtLanguage {',
    '    color:blue;',
    '    font-size:10px;',
    '}',
    '.txtSAEP {',
    '    color:brown;',
    '}',
    '.downloaded .poid{',
    '    text-decoration:line-through;',
    '}',
    '.downloaded img{',
    '    border:1px solid #9F9F9F;',
    '    -webkit-clip-path: polygon(52% 50%, 78% 11%, 86% 19%, 51% 71%, 28% 30%, 39% 24%);',
    '    clip-path: polygon(52% 50%, 78% 11%, 86% 19%, 51% 71%, 28% 30%, 39% 24%);',
    '}',
    'a.downloaded:active img{',
    '    -webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 0);',
    '    clip-path: polygon(100% 0, 100% 100%, 0 100%, 0 0);',
    '}',
    'a.downloaded:hover img{',
    '    -webkit-clip-path: polygon(95% 5%, 95% 95%, 5% 95%, 5% 5%);',
    '    clip-path: polygon(95% 5%, 95% 95%, 5% 95%, 5% 5%);',
    '}',
 '</style>'].join("\n")+'</style>'));

var addTag = function (text,tag,keywords){
    for(var k in keywords){
        text = text.replace(' '+keywords[k]+' ', function myFunction(x){
            return ' <span class="'+tag+'">'+x+'</span> ';
        });
    }
    return text;
};

$('.col-sm-4.cus-col.content-right-col').hide();

$('div.table-responsive > table.table tr').each(function(k,tr){
    var tds=$('td',tr);
    if(tds && tds.length>0){
        var atitles=$('a',tds[1]);
        var anfos=$('a',tds[2]);
        if(atitles && atitles.length>0){
            var m = anfos[0].href.match(/torrent\/(.*)/);
            $(anfos[0]).replaceWith('<a href="/get_torrent/'+m[1]+'.torrent">dwn</a>');
            //console.log(atitles[0].href);
            //console.log(m[1],atitles[0].innerHTML);
        }
    }
});

var idx=0;
$('div.left-tab-section').append('');
$('div.table-responsive table tr a').each(function(k,v){
    idx=++idx%4;
    var that    = $(v).closest('tr');
    var title   = ' '+$('td:eq(0)',that).text()+' ';
    var poid    = $('td:eq(1)',that).html();
    var up      = $('td:eq(2)',that).html();
    var down    = $('td:eq(3)',that).html();
    var match   = $('a',that).attr('href').match(/(.*)\/torrent\/(.*)/);
    var torrent = '/get_torrent/'+match[2]+'.torrent';
    var hash    = 'dwn_'+match[2];
    var inner   = "";
console.log(title);
    title = addTag(title,'txtQuality',['BluRay 720p','BluRay 1080p','DVDRIP','HDRIP','BRRIP','WEBRIP','x264','HDTV']);
    title = addTag(title,'txtLanguage',['VOSTFR','TRUEFRENCH','FRENCH']);
    title = addTag(title,'txtYear',(function(){var t=[];for(var i=1990;i<=2040;i++){t.push(''+i);}return t;})());
    var saep = title.match(/S([0-9]+)E([0-9]+)/);
    if(saep){
        title = title.replace(saep[0],' <span class="txtSAEP">['+saep[1]+'x'+saep[2]+']</span> ');
    }

    var downloaded=(window.localStorage.getItem(hash) !== null);

    title = title.replace(/  /g,' ');
    inner = inner + '<div class="ligne'+(idx>=2?1:0)+'">';
    inner = inner + '    <a class="dwnThumb torrentdwn '+(downloaded?'downloaded':'')+'" data-dhash="'+hash+'" href="'+torrent+'" alt="download torrent" title="download torrent"><img width="50 "src="/_pictures/'+match[2].replace(/^[0-9]*\//,'')+'.jpg"></a>';
    inner = inner + '    <a class="titre" href="'+$(v).attr('href')+'">'+title+'</a>';
    inner = inner + '    <div class="datas">';
    inner = inner + '        <a class="torrentdwn '+(downloaded?'downloaded':'')+'" alt="download torrent" title="download torrent" data-dhash="'+hash+'" href="'+torrent+'">';
    inner = inner + '            <div class="poid">'+poid+'</div>';
    inner = inner + '        </a>';
    inner = inner + '        <div class="up">'+up+'</div>';
    inner = inner + '        <div class="down">'+down+'</div>';
    inner = inner + '    </div>';
    inner = inner + '</div>';
    that.replaceWith('');
    $('div.left-tab-section').append(inner);
});

$('a.torrentdwn').bind('click',function(v){
    var hash = $(v.target).parent().attr('data-dhash');
    $('[data-dhash='+hash+']').addClass('downloaded');
    window.localStorage.setItem(hash,1);
    //console.log($(v.target)[0]);
    //console.log(hash);
    return true;
});
$('.gauche').show();

$('.left-tab-section div').first().hide();
长期地址
遇到问题?请前往 GitHub 提 Issues。