Set Arrival Time

Set the desired arrival time in Tribal Wars and the script will automatically send the attack

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name Set Arrival Time
// @description Set the desired arrival time in Tribal Wars and the script will automatically send the attack
// @author FunnyPocketBook
// @version 3.1
// @date 2018-05-20
// @namespace FunnyPocketBook
// @include https://*/game.php?village=*&screen=place&try=confirm
// ==/UserScript==

let inputMs;
let input;
let delay;
const showArrTimeTr = document.createElement("tr"); // Create button called btn as a link because any button causes the attack to launch
const showArrTimeTd = document.createElement("td");
const pEle = document.getElementById("troop_confirm_go"); // Button comes after this element
const btn = document.createElement("a"); // Create button called btn as a link because any button causes the attack to launch
btn.setAttribute("id", "arrTime"); // Set ID of btn
btn.setAttribute("class", "btn"); // Set ID of btn
btn.setAttribute("style", "cursor:pointer;"); // Set cursor to pointer
pEle.parentNode.insertBefore(btn, pEle.nextElementSibling); // Place btn after pEle
const t = document.createTextNode("Set arrival time"); // btn has this text
btn.appendChild(t); // Append text to btn

btn.onclick = function() {
	"use strict";
	let time = document.getElementsByClassName("relative_time")[0].textContent.slice(-8);
	let lalau = document.getElementById("date_arrival");
	input = prompt("Please enter desired arrival time", time);
	inputMs = parseInt(prompt("Please enter approximate milliseconds", "000"));
    delay = parseInt(delayTime) + parseInt(inputMs);
	showArrTimeTr.appendChild(showArrTimeTd);
	lalau.parentNode.parentNode.insertBefore(showArrTimeTr, lalau.parentNode[1]);
	showArrTimeTd.innerHTML = "Set arrival: ~" + input + ":" + inputMs;
	showArrTimeTd.setAttribute("colspan", "2");
	showArrTimeTd.setAttribute("id", "showArrTime");
};

let delayTime = parseInt(localStorage.delayTime);
if(delayTime == null) {
    delayTime = 0;
    localStorage.delayTime = JSON.stringify(delayTime);
}

// Create okay button to save delay
const delayTr = document.createElement("tr");
const delayTd1 = document.createElement("td");
const delayTd2 = document.createElement("td");
const parent1 = document.querySelector("#date_arrival"); // Cell of relative_time
delayTr.appendChild(delayTd1);
delayTr.appendChild(delayTd2);
parent1.parentNode.parentNode.insertBefore(delayTr, parent1.parentNode[1]); // Insert tablerow as last cell
delayTd1.innerHTML = "Offset";
delayTd2.innerHTML = "<input id = 'delayInput' value = " + delayTime + " style = 'width: 50%'></input> <a id = 'delayButton' class = 'btn'>OK</a>";

//debugger;
$("#delayButton").click(function() {
    delayTime = parseInt($("#delayInput").val());
    localStorage.delayTime =  JSON.stringify(delayTime);
    delay = parseInt(delayTime) + parseInt(inputMs); // setTimeout time
    if(delay < 0) {
        delay = 0;
    }
})

let arrival;
setInterval(function retime() {
	"use strict";
	arrival = document.getElementsByClassName("relative_time")[0].textContent;
	if(arrival.slice(-8) === input) {
		setTimeout(function() {document.getElementById("troop_confirm_go").click();}, delay);
	}
}, 1);