HOF Warbase Helper

Highlights potential war targets in green on HOF page

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         HOF Warbase Helper
// @namespace    namespace
// @version      0.2
// @description  Highlights potential war targets in green on HOF page
// @author       tos
// @match        *.torn.com/halloffame.php*
// @grant        none
// ==/UserScript==

APIkey = 'APIKEY'; //API KEY HERE
myFac = 'facID';  //YOUR FACTION ID HERE
minFacSize = 50;     //Set minimum faction size here
badTargets = [myFac]; //can use commas to add more factions not to target here eg. [myfac, '23', '1028']

$.ajax({
    type: "GET",
    url: 'https://api.torn.com/faction/'+ myFac +'?selections=basic&key='+ APIkey,
    success: function (response) {
        var wars = Object.keys(response.wars);
        var naps = Object.keys(response.naps);
        var peace = Object.keys(response.peace);
        for(i=0; i < wars.length; i++){
            badTargets.push(wars[i]);
        }
        for(i=0; i < naps.length; i++){
            badTargets.push(naps[i]);
        }
        for(i=0; i < peace.length; i++){
            badTargets.push(peace[i]);
        }
    }
});

const observer = new MutationObserver((mutations) => {
    for (const mutation of mutations) {
        for (const node of mutation.addedNodes) {
            try{
                if(node.className === 'hall-of-fame-wrap respect m-bottom10'){
                    var factionList = node.querySelector('.players-list').children;
                    for(i=0; i < factionList.length; i++){
                        var facSize = parseInt(factionList[i].querySelector('.acc-wrap .player-info').children[0].innerText);
                        var facID = factionList[i].querySelector('.acc-header .player-info .player').children[1].href.split('ID=')[1];
                        if(facSize >= minFacSize && !badTargets.includes(facID)){
                            factionList[i].style.backgroundColor = '#d7e1cc';
                        }
                    }
                }
            }
            catch(err){
                console.log(err);
            }
        }
    }
});
const wrapper = document.querySelector('#mainContainer .hall-of-fame-list-wrap');
observer.observe(wrapper, { subtree: true, childList: true });