ismail farm

auto farm script for tribalwars.

目前為 2023-01-30 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name ismail farm
// @author ismail.yankayis
// @version 1.0.0
// @grant Public
// @description auto farm script for tribalwars.
// @include        http*://*.tribalwars.net/*screen=am_farm*
// @include        https*://*.klanlar.org/*screen=am_farm*
// @namespace https://greasyfork.org/users/1019070
// @license MIT
// ==/UserScript==

var botProtect = $('body').data('bot-protect');
if (document.URL.indexOf('screen=am_farm') == -1)
    console.log('Você deve executar o script no assistente de farm!');
else if (botProtect !== undefined) {
    alert('Alerta Captcha!');
}
else {
    var count = 1,
        menu = $('#am_widget_Farm a.farm_icon_a'),
        attackInterval = 500,
        minhaVar = "",
        changeVillage = true,
        changeVillageInterval = 300000,
        refreshPage = false,
        refreshPageInterval = 25000,
        lootAssistantPageSize = 100,
        boxCaptcha = $("#bot_check");

    var randomTime = function (superior, inferior) {
        var numPosibilidades = superior - inferior,
            aleat = Math.random() * numPosibilidades;

        return Math.round(parseInt(inferior) + aleat);
    };

    if (attackInterval === "random") {
        attackInterval = randomTime(5000, 10000);
    }
    if (refreshPageInterval === "random") {
        refreshPageInterval = randomTime(700000, 800000);
    }

    $('img').each(function () {
        var tempStr = $(this).attr('src');
        if (tempStr.indexOf('attack') != -1)
            $(this).addClass('tooltip');
    });

    if (refreshPage === true) {
        setInterval(function () {
            window.location.reload();
        }, refreshPageInterval);
    }

    if (changeVillageInterval !== false) {
        if (changeVillageInterval === true)
            if ($('#light').text() >= 1)
                changeVillageInterval = randomTime(100000, 150000);
            else
                changeVillageInterval = randomTime(3000, 5000);
        else
            changeVillageInterval = parseInt(changeVillageInterval) + parseInt(randomTime(500, 1000));
    }
}

for (i = 0; i < lootAssistantPageSize; i++) {
    // wall level control
    //if(parseInt($('#plunder_list tr:not(:first)').eq(i + 1).find('td').eq(6).text()) == 0 || isNaN($('#plunder_list tr:not(:first)').eq(i + 1).find('td').eq(6).text()) == true){
    $(menu).eq(i).each(function () {
        var intervalOfNexAttack = attackInterval * count;
        setTimeout(function (minhaVar) {
            if ($('#light').text() >= 5) {
                $(minhaVar).click();
            }
        }, intervalOfNexAttack, this);
        ++count;
    });
    // }
}


if (changeVillage === true) {
    var altVillage = setInterval(function () {
        $('.arrowRight, .groupRight').click();

        clearInterval(altVillage);
    }, changeVillageInterval);
}


var checkCaptcha = setInterval(function () {
    if (boxCaptcha.length) {
        alert('Captcha found!');
        clearInterval(checkCaptcha);
        clearInterval(altVillage);
    }
}, 100);