HOF Warbase Helper

Highlights potential war targets in green on HOF page

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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 });