Torn Revive Contract

Filter faction member list to only show online and hospitalized

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         Torn Revive Contract
// @namespace    https://tampermonkey.net/
// @version      1.3
// @description  Filter faction member list to only show online and hospitalized
// @author       Marabon
// @match        https://www.torn.com/factions.php*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var factioninfowrap = $('.faction-info-wrap').children('.f-war-list');
    var memberlist = factioninfowrap.children('.member-list');
    var storedactive = window.localStorage.getItem('togglereviveactive');
    var active = false;

    if(storedactive == 'true')
    {
        active = true;
    }

    showOnlyRevived();

    factioninfowrap.prepend('<button id="togglerevive" name="togglerevive" type="button">Toggle Revive Only</button>');

    $("#togglerevive").click(toggleRevived);

    function toggleRevived(){
        if(active)
        {
            active = false;
            window.localStorage.setItem('togglereviveactive', 'false');
            console.log('Togglereviveactive set to false');
        }
        else
        {
            active = true;
            window.localStorage.setItem('togglereviveactive', 'true');
            console.log('Togglereviveactive set to true');
        }

        showOnlyRevived();
    }

    function showOnlyRevived(){
        var list = memberlist.children('li');

        list.each(function (index){
            var row = $(this);
            var accwrap = row.children('.acc-wrap');
            var hospreason = accwrap.children('.member-icons').children('ul').children('#icon15').attr('title');
            var status = accwrap.children('.info-wrap').children('.status').children().eq(1).text();
            var hospitalized = false;

            if(typeof hospreason != 'undefined')
            {
                if(~hospreason.indexOf("Hospitalized"))
                {
                    hospitalized = true;
                }
            }

            if(status != 'Hospital' || hospitalized == false)
            {
                if(active)
                {
                    row.attr('style', 'display: none;');
                }
                else
                {
                    row.attr('style', '');
                }
            }
        });

        var factionDesc = $('.faction-description');

        if(active)
        {
            factionDesc.attr('style', 'display: none;');
        }
        else
        {
            factionDesc.attr('style', '');
        }
    }
})();