War Base Faction Highlighter

Highlights factions in the war based that are linked to in the faction announcement.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         War Base Faction Highlighter
// @version      0.5
// @description  Highlights factions in the war based that are linked to in the faction announcement.
// @author       Ashkill94
// @match        http://http://www.torn.com/factions.php?step=your
// @grant        none
// @namespace    none
// ==/UserScript==

$(function(){
    var flag = "fhbChecked";
    
	setInterval(function() {
		var a = $("#faction-main > .title-black").next("div.cont-gray10");
		if (a.length != 1 || a.attr(flag) != null) {
			return;
		}
        var fId, b;
        
        // Normal War Base
        $('.f-war-list > li > .status-wrap > .info > .name > a').each(function(i, ele) {
            fId = $(ele).attr("href").match(/factions\.php\?step=profile&ID=(\d+)/);
            if (fId) {
                b = $(ele).parentsUntil(".f-war-list").last().attr('factionId', fId[1]);
                $("> .desc-wrap > .status-desc", b).attr('factionId', fId[1]);
            }
		});
        
        // War Base Extended Compatibility
        $('.f-war-list > li > .status-desc > .f-right > .cont > .bold > a').each(function(i, ele) {
            fId = $(ele).attr("href").match(/factions\.php\?step=profile&ID=(\d+)/);
            if (fId) {
                b = $("> .status-desc", $(ele).parentsUntil(".f-war-list").last()).attr('factionId', fId[1]);
            }
		});
        
		var bonusFactions = a.find("a[href*='factions.php?step=profile&ID=']["+flag+"!=]").attr(flag, "");
		bonusFactions.each(function(i, ele) {
			var bonusFaction = $(ele);
			var id = bonusFaction.attr("href").match(/factions\.php\?step=profile&ID=(\d+)/);
            if (id) {
                console.debug("Bonus faction found! "+id[1]);
                $("[factionId='"+id[1]+"'").css("background-color", "red");
            }
		});
		
		a.attr(flag, "")
	}, 500);
});