TribalWars Simple Collector Script

01/13/2020 01:57 cron1003#1
(Maybe there's a chance of ban...)

Put what you want to use in units

Then go to collector page > press f12 > console > paste the code:

Have fun :)

PHP Code:
const autoCollector = {
    
units: [
        {
'spear'0},
        {
'sword'0},
        {
'axe'0},
        {
'archer'0},
        {
'light'0},
        {
'marcher'0},
        {
'heavy'0},
        {
'knight'0}
    ],
    
intervalId0,
    
percents: [0.620.270.11],
    
optionsdocument.getElementsByClassName("options-container")[0].children,
    
setUnitAmount(nameamount) {
        const 
element document.getElementsByName(name)[0];

        
element.value amount;
        
element.dispatchEvent(new Event('change'));
    },
    
unitAvailable: function (name) {
        const 
field document.getElementsByName(name)[0];
        const 
text field.parentNode.lastChild.innerHTML;
        return +(
text.substr(1text.length 2));
    },
    
calculateAndSetUnits: function (level) {
        const 
percent this.percents[level];

        for (
let i 0this.units.lengthi++) {
            const 
current this.units[i];

            const 
name Object.keys(current);
            const 
amount Math.floor(current[name] * percent);
            const 
available this.unitAvailable(name);

            
this.setUnitAmount(nameMath.min(amountavailable));
        }
    },
    
tick: function () {
        for (
let i 0this.options.lengthi++) {
            const 
element this.options[i].lastChild.lastChild;

            if (
element.classList.contains("inactive-view")) {

                if (
element.firstChild === null)
                    continue;

                
this.calculateAndSetUnits(i);
                
element.lastChild.firstChild.click();
                break;
            }
        }
    },
    
start: function () {
        if (
this.intervalId !== 0)
            throw new 
Error("Already started!");
        else
            
this.intervalId setInterval(() => this.tick(), 10000)
    },
    
stop: function () {
        if (
this.intervalId === 0)
            throw new 
Error("Not started yet!");
        else {
            
clearInterval(this.intervalId);
            
this.intervalId 0;
        }
    }
};

autoCollector.start();