Anti-DMCA script for KAT

Started by PXgamer & UnDeAd.YeTii (making the magnet link)

当前为 2015-07-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Anti-DMCA script for KAT
// @include     http*://kickass.so/*.html*
// @include     http*://kickass.to/*.html*
// @include     http*://kat.ph/*.html*
// @include     http*://kat.cr/*.html*
// @include     http*://kickassto.co/*.html*
// @include     http*://katproxy.is/*.html*
// @include     http*://thekat.tv/*.html*
// @version     2.5
// @grant       none
// @description Started by PXgamer & UnDeAd.YeTii (making the magnet link)
// @namespace   https://greasyfork.org/users/9596
// ==/UserScript==

// if on torrent page and if DMCA'd
if (/-t\d+\.html($|#.*)/.test(window.location.pathname)&&$('.alertfield').length) {
    // add tracker tab
    $('.tabs .tabNavigation li:first').after(' <li><a href="#technical" rel="technical" class="darkButton"><span>Technical</span></a></li>')
    
    // get hash and name for magnet link
    var hash = $('#tab-technical .lightgrey').text().split(': ')[1];
    var name = window.location.pathname.split('/')[1];
    name = name.substring(0, name.lastIndexOf("-"));
    
    // compile technical stats
    var trackers = [];
    $('#trackers_table tr:not(.firstr)').each(function() {
      trackers.push({'url':$('td:eq(0)', $(this)).text(), 'seed':padNum($('td:eq(3)', $(this)).text()), 'leech':padNum($('td:eq(4)', $(this)).text())});
    })
    
    // get highest seed and tracker for it
    trackers.sort(function(a, b) {
       var x = a['seed']; var y = b['seed'];
       return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    });
    var seed = parseInt(trackers[trackers.length-1].seed);
    var tracker = trackers[trackers.length-1].url;
    
    // get highest leech
    trackers.sort(function(a, b) {
       var x = a['leech']; var y = b['leech'];
       return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    });
    var leech = parseInt(trackers[trackers.length-1].leech);
    // if no seeders, try the one with leechers
    if (seed == 0 && leech > 0)
        var tracker = trackers[trackers.length-1].url;

    var values = '<div class="seedLeachContainer" title="These are the last updated values, they are likely not up to date"><div class="seedBlock"><span class="seedLeachIcon"></span>seeders: <strong itemprop="seeders">'+seed+'</strong></div><div class="leechBlock"><span class="seedLeachIcon"></span>leechers: <strong itemprop="leechers">'+leech+'</strong></div></div>';

    var verified = $('.tabs.tabSwitcher').prev().text().indexOf('Torrent verified') >= 0;
    
    var buttonGroup = '<div class="buttonsline downloadButtonGroup clearleft novertpad"><a title="Add torrent to personal RSS" href="/bookmarks/add/rss/'+hash+'/" class="siteButton giantIcon rssButton postLink"><span></span></a> <a title="Magnet link" href="magnet:?xt=urn:btih:'+hash+'&dn='+name+'&tr='+tracker+'" class="siteButton giantIcon magnetlinkButton askFeedbackjs" data-id="'+hash+'"><span></span></a> <a rel="nofollow" title="Download torrent file (if it does not work, try magnet link)" href="http://torcache.net/torrent/'+hash+'.torrent" class="siteButton giantButton askFeedbackjs    '+(verified?'verifTorrentButton':'')+'"><span>'+(verified?'<em class="buttonPic"></em>':'')+'Download torrent</span></a></div>';
    $('.alertfield').after(values+buttonGroup);
}

function padNum(num) { // 123 ==> 000123
    num = '00000000'+num;
    return num.substring(num.length-7, num.length);
}