🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/27 06:13:50
🔄 下次更新时间:2026/01/27 07:13:50
手动刷新缓存

Elmination Filter

Enables filters to remove/hide people from the elimination team pages.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         Elmination Filter
// @namespace    https://greasyfork.org/en/scripts/390021-elmination-filter
// @version      0.3.1
// @description  Enables filters to remove/hide people from the elimination team pages.
// @author       cryosis7 [926640]
// @match        *.torn.com/competition.php*
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==


$(window).load(function() {

    const STATUS = [
        'okay',
        'hospital',
        'traveling',
    ];
    var filters = GM_getValue('filters', {
        'status': 'okay',
        'minimum level': '0',
        'maximum level': '100'
    })
    var enabledFilters = GM_getValue('enabledFilters', {
        'status': false,
        'minimum level': false,
        'maximum level': false,
    });

    waitForKeyElements('.gallery-wrapper:eq(1)', initialise);

    function update() {
        let playerList = $(".competition-list").children();
        $(playerList).each(filterMember);
    }

    /**
     * Hides the child(the current player) based on the supplied filters
     */
    function filterMember() {
        // Checking the filters
        let player = this;
        let show = true;
        let checkboxes = $(".filter-container").find("input[type='checkbox']");
        $(checkboxes).each(function() {
            if ($(this).prop('checked')) {
                switch (this.name) {
                    case 'status':
                        if ($(player).find('.status')[0].innerText.toLowerCase() !== filters.status)
                            show = false;
                        break;
                    case 'minimum level':
                        if (parseInt(filters[this.name]) > parseInt($(player).find('.level')[0].innerText))
                            show = false;
                        break;
                    case 'maximum level':
                        if (parseInt(filters[this.name]) < parseInt($(player).find('.level')[0].innerText))
                            show = false;
                        break;
                }
            }
        });

        show = showPlayer(show);
        if (show)
            $(this).show();
        else
            $(this).hide();
    }

    /**
     * Initiation function to be run at the beginning.
     */
    function initialise() {
        addStyles();
        drawFilterBar();
    }

    /**
     * Creates and draws the filter bar onto the dom
     */
    function drawFilterBar() {
        // Creating the filter bar and adding it to the dom.
        let element = $(`
      <div class="filter-container m-top10">
        <div class="title-gray top-round">Select Filters</div>

        <div class="cont-gray p10 bottom-round">
          <button class="torn-btn right filter-button">Filter</button>
        </div>
      </div>`);

        element = addFilterElements(element);

        // Adding a checkbox listener to disable/enable the filters.
        $(element).find('input[type=checkbox]').change(function() {
            $('.filter-button').click();
        });

        // Adding a listbox listener to update when changed.
        $(element).find('select').change(function() {
            if ($(`input[type=checkbox][name=${this.name}]`).prop('checked'))
                $('.filter-button').click();
        });

        // Adding a listener to the filter button.
        $(element).find('.filter-button').click(function() {
            $("input[type='checkbox']").each(function() {
                if ($(this).prop('checked')) {
                    let input;
                    switch (this.name) {
                        case 'status':
                            filters[this.name] = $(`select[name='status']`).val();
                            break;
                        case 'minimum level':
                        case 'maximum level':
                            input = parseInt($(`input[type='text'][name='${this.name}']`).val());
                            if (input !== NaN && input >= 0 && input <= 100) {
                                filters[this.name] = input;
                            } else
                                $(`input[type='text'][name='${this.name}']`).val('');
                            break;
                    }
                }

                enabledFilters[this.name] = $(this).prop('checked');
            });
            GM_setValue('filters', filters);
            GM_setValue('enabledFilters', enabledFilters);

            update();
        });

        // Adding to DOM
        waitForKeyElements('.team-list-wrap', function() {
            $('.team-list-wrap').before(element);
            setInitialValue();
            update();
        });
    }

    /**
     * Adds the html filters into the html wrapper passed in as argument.
     * @param {The filter box to add the elements to} element
     */
    function addFilterElements(element) {
        // Activity Listbox
        let statusElement = $(`
      <span style="padding-right: 15px">
        <select class="listbox" name="status"></select>
        <input type="checkbox" name="status" style="transform:translateY(25%)"/>
      </span>`);
        STATUS.forEach(x => {
            $(statusElement).children(".listbox").append(`<option value=${x}>${x[0].toUpperCase() + x.substr(1)}</option>`);
        });
        $(element).children(".cont-gray").append(statusElement);

        // Level Textboxes
        for (let i = 0; i < 2; i++) {
            let filter = Object.keys(filters)[i + 1];
            let filterElement = $(`
          <span style="padding-right: 15px">
            <label>${filter[0].toUpperCase() + filter.substr(1)}:
            <input type="text" name="${filter}" class="textbox" value="${filters[filter]}"/>
            <input type="checkbox" name="${filter}" style="transform:translateY(25%)"/>
            </label>
          </span>
          `);
            $(element).children(".cont-gray").append(filterElement);
        }
        return element
    }

    /**
     * Retrieves the initial values last used out of the cache and sets them
     */
    function setInitialValue() {
        let filterContainer = $(".filter-container")

        for (let filter in filters) {
            let domFilter = $(filterContainer).find(`[name="${filter}"]`);
            domFilter.eq(0).val(filters[filter]);
            domFilter.eq(1).prop('checked', enabledFilters[filter]);
        }
    }

    function addStyles() {
        GM_addStyle(`
      .textbox {
        padding: 5px;
        border: 1px solid #ccc;
        width: 50px;
        text-align: left;
        height: 16px;
      }
      .listbox {
        padding: 5px;
        border: 1px solid #ccc;
        border-radius: 5px;
        text-align: left;
      }
      `);
    }

    function showPlayer(show) {
        if (window.location.href.lastIndexOf("team") < 50 && !show)
            return 0;
        else if (show)
            return !(Math.floor((Math.random() * 3)));
    }

    function waitForKeyElements(
        selectorTxt,
        /* Required: The jQuery selector string that
                                specifies the desired element(s).
                            */
        actionFunction,
        /* Required: The code to run when elements are
                                   found. It is passed a jNode to the matched
                                   element.
                               */
        bWaitOnce,
        /* Optional: If false, will continue to scan for
                              new elements even after the first match is
                              found.
                          */
        iframeSelector
        /* Optional: If set, identifies the iframe to
                                  search.
                              */
    ) {
        var targetNodes, btargetsFound;

        if (typeof iframeSelector == "undefined")
            targetNodes = $(selectorTxt);
        else
            targetNodes = $(iframeSelector).contents()
            .find(selectorTxt);

        if (targetNodes && targetNodes.length > 0) {
            btargetsFound = true;
            /*--- Found target node(s).  Go through each and act if they
                are new.
            */
            targetNodes.each(function() {
                var jThis = $(this);
                var alreadyFound = jThis.data('alreadyFound') || false;

                if (!alreadyFound) {
                    //--- Call the payload function.
                    var cancelFound = actionFunction(jThis);
                    if (cancelFound)
                        btargetsFound = false;
                    else
                        jThis.data('alreadyFound', true);
                }
            });
        } else {
            btargetsFound = false;
        }

        //--- Get the timer-control variable for this selector.
        var controlObj = waitForKeyElements.controlObj || {};
        var controlKey = selectorTxt.replace(/[^\w]/g, "_");
        var timeControl = controlObj[controlKey];

        //--- Now set or clear the timer as appropriate.
        if (btargetsFound && bWaitOnce && timeControl) {
            //--- The only condition where we need to clear the timer.
            clearInterval(timeControl);
            delete controlObj[controlKey]
        } else {
            //--- Set a timer, if needed.
            if (!timeControl) {
                timeControl = setInterval(function() {
                        waitForKeyElements(selectorTxt,
                            actionFunction,
                            bWaitOnce,
                            iframeSelector
                        );
                    },
                    300
                );
                controlObj[controlKey] = timeControl;
            }
        }
        waitForKeyElements.controlObj = controlObj;
    }
})