Anti-DMCA script for KAT

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

目前為 2015-07-14 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
}