Auto Select Next Explorer

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

目前為 2015-05-09 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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;
        window.Timeout(autoSelectNextExplorer,250);
        }
        
    }
    
}  

// 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);