HDC Selector

Automatic add eligible torrents to rsscart. You must have a HDChina account first.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         HDC Selector
// @name         HDC检查器
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Automatic add eligible torrents to rsscart. You must have a HDChina account first.
// @description  Visit https://hdchina.org/torrents.php and leave the page alone, it will be refreshed every 5 minutes to check torrents.
// @description  You can change the condicions max_size, max_seed and refresh below.
// @description  自动添加符合条件的种子到下载框。你必须先有一个HDChina的账号。
// @description  打开https://hdchina.org/torrents.php页面,窗口会每5分钟自动刷新检查是否有符合条件的种子。
// @description  你可以修改下方的添加条件max_size(最大尺寸)、max_seed(当前做种数)和refresh(刷新间隔)。
// @author       Garydz
// @match        https://hdchina.org/torrents.php
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var max_size = 10; //  only automatic add torrents < 10 GB
    var max_seed = 4;  //  and current seeders < 4
    var refresh = 5;   //  every 5 minutes
    function find_pnode(o){
        var pn = o;
        do{
            pn = pn.parentNode;
        }while(pn.className != 't_name');
        return pn;
    }
    function find_sibling(o, cls_name){
        var sn = o;
        do{
            sn = sn.nextSibling;
        }while(sn.className != cls_name);
        return sn;
    }
    function check_torrents(arr){
        var l = arr.length;
        for(var i=0;i<l;i++){
            var t = find_pnode(arr[i]);
            var bm = t.getElementsByClassName('delbookmark_rss');
            if(bm.length > 0){
                var t_size = find_sibling(t, 't_size').innerText;
                if((t_size.indexOf('MB')>0) || (t_size.indexOf('GB') && (parseInt(t_size) < max_size))){
                    var t_torrents = parseInt(find_sibling(t, 't_torrents').innerText);
                    if(t_torrents < max_seed){
                        bm[0].parentNode.click();
                    }
                }
            }
        }
    }
    var freebies = document.getElementsByClassName('pro_free');
    check_torrents(freebies);
    setTimeout("window.location.reload()", refresh*60000);
})();