Busca Minuciosa

Ativa a busca minuciosa em loop

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Busca Minuciosa
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Ativa a busca minuciosa em loop 
// @author       Miguel Dinis
// @match        http://*/*
// @grant        none
// @include      http*://*.tribalwars.com.pt/*
// ==/UserScript==

var loop;
var timeEachScavenge = 10000; // in ms
var counter = 0;
var counterCap = 1;

(function() {
    'use strict';

    // checkbox
    if (checkPage("mode", "scavenge")) {
		
		
        var d = document.getElementById("content_value");
		
        var cb = document.createElement("input");
        cb.id = "cb";
        cb.type = "checkbox";
		cb.onchange = function() { setHours(); };
		
		var hoursInput = document.createElement("input");
		hoursInput.id = "hoursInput";
		hoursInput.type = "number";
		
		var spanHours = document.createElement("span");
		spanHours.id = "spanHours";
		spanHours.innerText = "   number of hours you wish this script to run (round a bit down please)";
		
		var br = document.createElement("br");
		
		var selectScavenge = document.createElement("input");
		selectScavenge.id = "selectScavenge";
		selectScavenge.placeholder = "Scavenge Number";
		selectScavenge.type = "number";
		selectScavenge.min = "1";
		selectScavenge.max = "4";
		selectScavenge.value = "3";
		
        d.appendChild(cb);
		d.appendChild(hoursInput);
		d.appendChild(spanHours);
		d.appendChild(br);
		d.appendChild(selectScavenge);

        loop = setInterval(function() {
            if (cb.checked && (counter < counterCap)) {
                document.getElementsByClassName("fill-all")[0].click();
				var paladin_value = document.getElementsByClassName("unitsInput")[7].value;
				
				// if paladin value is 1, click again to clear. otherwise, dont click
				if (paladin_value == "1") {
					document.getElementsByClassName("units-entry-all")[7].click();
				}
				
				var scavengeNumber = document.getElementById("selectScavenge").value;
				
                document.getElementsByClassName("free_send_button")[scavengeNumber-1].click();
				
				counter++;
				
				console.log(counter);
				console.log(counterCap);
				console.log(scavengeNumber);
            }
        }, timeEachScavenge);
    }


})();

function checkPage(variable, value) {

    var query = window.location.search.substring(1);
    var vars = query.split("&");

    for (var i = 0; i < vars.length; i++) {
        var temp = vars[i].split("=");
        if (temp[0] == variable && temp[1] == value) return true;
    }

    return false;

}

function setHours() {
    var h = document.getElementById("hoursInput").value;
	counterCap = (h * 60 * 60 * 1000) / timeEachScavenge;
	counter = 0;
}