Torn Revive Contract

Filter faction member list to only show online and hospitalized

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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', '');
        }
    }
})();