Auto Select Next Explorer

Automatically Selects next Explorer When explorer is launched. For Warring Factions www.war-facts.com New Interface

当前为 2015-05-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Auto Select Next Explorer
// @namespace    https://greasyfork.org/en/users/10321-nikitas
// @version      1
// @description  Automatically Selects next Explorer When explorer is launched. For Warring Factions www.war-facts.com New Interface
// @author       guardian
// @match        http://*.war-facts.com/fleet.php*
// @grant        none
// ==/UserScript==

//Replaces game's getMission function, so that if it is an explorer it autolaunches
function newgetMission(){

    
    
//Configuration Options:
// Change this if you wish to exclude Fleets whose names contain the excludeString from being auto Selected as next explorer.
var useExcludeString = false;
// Change this to what you would like to put into a fleet's name in order to exclude it from being auto selected.
var excludeString = "#NotAuto#";


// Change this if you wish to auto Select Fleets as next explorer ONLY if their names contain the includeString.
var useIncludeString = false;
// Change this to what you would like to put into a fleet's name in order to include it into being auto selected.
var includeString = "#Auto#";

    
    
    
//Script




    function autoSelectNextExplorer(){

        var explorerList = document.getElementById('fc_Explorer').children;
        var index = 0;
        var explorerListLength = explorerList.length;
           
        while (index < explorerListLength) {

            if (explorerList[index].children[0].style.color == "rgb(242, 242, 242)") {
                
                var link = explorerList[index].children[0].href;
                var name = explorerList[index].children[0].innerHTML;
                 
                if (
                       ( ( !useIncludeString) || ( name.indexOf(includeString) > -1  )  ) //If not using include string or String is in name
                    && ( ( !useExcludeString) || ( name.indexOf(excludeString) == -1 )  ) //If not using exclude string or String is NOT in name
                    && ( link != window.location.href )  //Make sure we are not chosing ourselve as this fleet is still "white"
                   ) 
                {
                    
                    index = explorerListLength; //To make sure if load doesn't happen immediately it stops running through fleet list
                    window.open(link, "_self");
                }
            }
            index++;
        }
    }  

    
    
    
// Replace the site's getMission function, so that when launch is pressed, it autoSelectsNextExplorer
	var oldgetMission = getMission; 

	window.getMission = function getMission(action, dType) {
		var executed = new oldgetMission(action, dType);
        if (action == 'launch'){            
        var classificationNode = document.getElementById('fleetClass');
        var isExplorer = document.evaluate("//text()[contains(.,'Explorer') or contains(.,'Sentry') or contains(.,'Probe Rush')]", classificationNode, null, XPathResult.BOOLEAN_TYPE, null).booleanValue;
            autoSelectNextExplorer();
        }
        
    }
    
}  

// this is the only script injection technique I've found which works on Chrome with the above function
var inject = document.createElement("script");
inject.setAttribute("type", "text/javascript");
inject.appendChild(document.createTextNode("(" + newgetMission + ")()"));
document.body.appendChild(inject);