MADWAYZ / CSGODOUBLE BOT modified by Wizard&Madwayz

// ==UserScript==
// @name            CSGODOUBLE BOT modified by Wizard&Madwayz
// @description     An userscript that automates csgodouble.com betting using 6 chooseble systems.
// @namespace       automated by WizarD&MADWAYZ
// @version         0.7
// @author          Classico, modified@Wizard&MADWAYZ
// @match           http://www.csgodouble.com/
// @match           http://www.csgodouble.com/index.php
// @match           http://csgodouble.com/
// @match           http://csgodouble.com/index.php
// @run-at          document-end
// @grant           none
// ==/UserScript==

//http://www.danstools.com/javascript-obfuscate/index.php
//http://www.textfixer.com/html/compress-html-compression.php

'use strict';

var WS = new WebSocket("ws://csgodouble.com/");
var debug = false;
var simulation = false;
var stop_on_min_balance = false;
var calculate_safe_bet = false;
var base_bet = 5;
var safe_bet_amount = 6;
var default_color = 'red';
var default_method = 'great martingale';
var theme = 'light';

var colors = {
    'green': [0],
    'red': [1, 2, 3, 4, 5, 6, 7],
    'black': [8, 9, 10, 11, 12, 13, 14]
};

var balance = document.getElementById('balance');
var roll_history = document.getElementById('past');
var bet_input = document.getElementById('betAmount');
var bet_buttons = {
    'green': document.getElementById('panel0-0').childNodes[1].childNodes[1],
    'red': document.getElementById('panel1-7').childNodes[1].childNodes[1],
    'black': document.getElementById('panel8-14').childNodes[1].childNodes[1]
};

Array.prototype.equals = function(array) {
    if (!array) {
        return false;
    }

    if (this.length != array.length) {
        return false;
    }

    for (var i = 0, l=this.length; i < l; i++) {
        if (this[i] instanceof Array && array[i] instanceof Array) {
            if (!this[i].equals(array[i])) {
                return false;
            }
        } else if (this[i] != array[i]) {
            return false;
        }
    }
    return true;
};

Object.defineProperty(Array.prototype, "equals", {enumerable: false});

function Automated() {
    var self = this;

    this.running = false;
    this.game = null;

    this.debug = debug;
    this.simulation = simulation;
    this.stop_on_min_balance = stop_on_min_balance;
	this.calculate_safe_bet = calculate_safe_bet;

    this.base_bet = base_bet;
    this.default_color = default_color;
    this.default_method = default_method;
	this.safe_bet_amount = safe_bet_amount;
    this.method = this.default_method;
    this.old_method = '';
    this.color = 'rainbow';
    this.old_base = 0;
    this.balance = 0;
    this.last_bet = 0;
    this.bet_history = [];
    this.min_balance = 0;
    this.starting_balance = 0;
    this.last_color = null;
    this.last_result = null;
    this.history = [];
    this.waiting_for_bet = false;
    this.theme = theme;
	this.retry_connect = null;

    this.stats = {
        'wins': 0,
        'loses': 0,
        'balance': 0
    };

    var menu = document.createElement('div');
    menu.innerHTML = '' +
        '<div class="row">' +
            '<div class="col-lg-9">' +
                '<h2>CSGODouble.com БОТ <small>модифицирован by <span style="color:#FF3300"><b><a href="http://vk.com/madwayz_1337">MADWAYZ</a></b></span><span style="color:#FF3300">(76561198182120638)</span></small>' +
                '<div class="form-group">' +
                    '<div class="btn-group">' + 
                        '<button type="button" class="btn btn-success" id="automated-start" disabled>Старт</button>' +
                        '<button type="button" class="btn btn-warning" id="automated-stop" disabled>Пауза</button>' +
                        '<button type="button" class="btn btn-danger" id="automated-abort" disabled>Стоп</button>' +
                    '</div>' +
                '</div>' +
                '<div class="form-group">' +
                    '<div class="btn-group">' +
                        '<button type="button" class="btn btn-default" id="automated-martingale" ' + (this.method === 'martingale' ? 'disabled' : '') + '>Мартингейл</button>' +
                        '<button type="button" class="btn btn-default" id="automated-great-martingale" ' + (this.method === 'great martingale' ? 'disabled' : '') + '>Мартингейл +</button>' +
                        '<button type="button" class="btn btn-default" id="automated-dalembert" ' + (this.method === 'dalembert' ? 'disabled' : '') + '>Д\'аламберт</button>' +
                        '<button type="button" class="btn btn-default" id="automated-bet-green" ' + (this.method === 'green' ? 'disabled' : '') + '>Зеленые</button>' +
                    '</div>' +
                '</div>' +
                '<div class="form-group automated-hide-on-green">' +
                    '<div class="btn-group">' +
                        '<button type="button" class="btn btn-default" id="automated-red" ' + (this.color === 'red' ? 'disabled' : '') + '>Красные</button>' +
                        '<button type="button" class="btn btn-default" id="automated-black" ' + (this.color === 'black' ? 'disabled' : '') + '>Черные</button>' +
                        '<button type="button" class="btn btn-default" id="automated-rainbow" ' + (this.color === 'rainbow' ? 'disabled' : '') + '>Радугой</button>' +
                        '<button type="button" class="btn btn-default" id="automated-random" ' + (this.color === 'random' ? 'disabled' : '') + '>Случайные</button>' +
                        '<button type="button" class="btn btn-default" id="automated-last" ' + (this.color === 'last' ? 'disabled' : '') + '>Последнее выбранное</button>' +
                    '</div>' +
                '</div>' +
            '</div>' +
            '<div class="col-lg-3">' +
                '<h3>Статистика</h3>' +
                '<p><b><span style="color:#1AFF00">Победы:</span></b> <span id="automated-stats-wins">' + this.stats.wins + '</span></p>' +
                '<p><b><span style="color:#FF3300">Поражения:</span></b> <span id="automated-stats-loses">' + this.stats.loses + '</span></p>' +
                '<p><b><span style="color:#DF7401">Профит:</span></b> <span id="automated-stats-balance">' + this.stats.balance + '</span></p>' +
            '</div>' +
        '</div>' +
        '<div class="form-group">' +
            '<div class="input-group">' +
                '<div class="input-group-addon">Стандартная ставка</div>' +
                '<input type="number" class="form-control" placeholder="Значение" id="automated-base-bet" disabled>' +
            '</div>' +
        '</div>' +
        '<div class="form-group">' +
            '<div class="input-group">' +
                '<div class="input-group-addon">Держать баланс выше</div>' +
                '<input type="number" class="form-control" value="0" id="automated-min-balance">' +
            '</div>' +
        '</div>' +
        '<div class="form-group automated-hide-on-green">' +
            '<div class="input-group">' +
                '<div class="input-group-addon">Failsafe значение</div>' +
                '<input type="number" class="form-control" value="' + this.safe_bet_amount + '" id="automated-safe-bet-amount"' + (!this.calculate_safe_bet ? ' disabled' : '') + '>' +
            '</div>' +
        '</div>' +
        '<div class="checkbox">' +
            '<label><input class="" id="automated-stop-on-min-balance" type="checkbox" ' + (this.stop_on_min_balance ? 'checked' : '') + '> Остановиться на минимальном балансе</label>' +
        '</div>' +
        '<div class="checkbox automated-hide-on-green">' +
            '<label><input class="" id="automated-calculate-safe-bet" type="checkbox" ' + (this.calculate_safe_bet ? 'checked' : '') + '> Вычислить базовую ставку от данного "Failsafe значения", формула -> [base bet] = floor( [balance] / 2 ^ ( [failsafe value] + 1) ) </label>' +
        '</div>' +
		'<div class="checkbox">' +
            '<label ><input id="automated-simulation" type="checkbox" ' + (this.simulation ? 'checked' : '') + ' > Режим "симулятор"</label>' +
        '</div>' +
        '<div class="checkbox">' +
            '<label ><input class="" id="automated-debug" type="checkbox" ' + (this.debug ? 'checked' : '') + '> Режим отладки</label>' +
        '</div>' ;
    document.getElementsByClassName('well')[1].appendChild(menu);

    this.menu = {
        'start': document.getElementById('automated-start'),
        'stop': document.getElementById('automated-stop'),
        'abort': document.getElementById('automated-abort'),
        'basebet': document.getElementById('automated-base-bet'),
        'minbalance': document.getElementById('automated-min-balance'),
        'debug': document.getElementById('automated-debug'),
        'simulation': document.getElementById('automated-simulation'),
        'stoponminbalance': document.getElementById('automated-stop-on-min-balance'),
        'red': document.getElementById('automated-red'),
        'black': document.getElementById('automated-black'),
        'rainbow': document.getElementById('automated-rainbow'),
        'random': document.getElementById('automated-random'),
        'last': document.getElementById('automated-last'),
        'statistics': {
            'wins': document.getElementById('automated-stats-wins'),
            'loses': document.getElementById('automated-stats-loses'),
            'balance': document.getElementById('automated-stats-balance')
        },
        'theme': document.getElementById('automated-theme-switch'),
		'safebetamount': document.getElementById('automated-safe-bet-amount'),
		'calculatesafebet': document.getElementById('automated-calculate-safe-bet'),
        'martingale': document.getElementById('automated-martingale'),
        'greatmartingale': document.getElementById('automated-great-martingale'),
        'betgreen': document.getElementById('automated-bet-green'),
        'dalembert': document.getElementById('automated-dalembert'),
        'hideongreen': document.getElementsByClassName('automated-hide-on-green')
    };

    this.updater = setInterval(function() { // Update every 2 seconds
        if (!self.running) {
            if (self.updateAll()) {
				if (self.calculate_safe_bet) {
					self.base_bet = Math.floor(self.balance / Math.pow(2, self.safe_bet_amount + 1));
					self.menu.basebet.value = self.base_bet;
                    if (self.debug) { self.logdebug('Новая стандартная ставка: ' + self.base_bet); }
				}
				
				if (self.menu.stop.disabled && self.menu.start.disabled) {
					self.menu.start.disabled = false;
                    self.base_bet = Math.floor(self.balance / Math.pow(2, self.safe_bet_amount + 1));
                    self.menu.basebet.value = self.base_bet;
					self.menu.basebet.disabled = self.menu.calculatesafebet.checked;
					self.starting_balance = self.balance;
				}
            }
        }
    }, 2 * 1000);

    if (theme === 'dark') {
        this.darkMode();
    }

    this.menu.start.onclick = function() {

    self.start();
    };

    this.menu.stop.onclick = function() {
        self.stop();
    };

    this.menu.abort.onclick = function() {
        self.stop(true);
    };

    this.menu.basebet.onchange = function() {
        var value = parseInt(self.menu.basebet.value);
        if (!isNaN(value)) {
            self.base_bet = value;
        }
    };

    this.menu.minbalance.onchange = function() {
        var value = parseInt(self.menu.minbalance.value);
        if (!isNaN(value)) {
            self.min_balance = value;
        }
    };

    this.menu.safebetamount.onchange = function() {
        var value = parseInt(self.menu.safebetamount.value);
        if (!isNaN(value)) {
            self.safe_bet_amount = value;
        }
    };

    this.menu.debug.onchange = function() {
        self.debug = self.menu.debug.checked;
    };

    this.menu.simulation.onchange = function() {
        self.simulation = self.menu.simulation.checked;
    };

    this.menu.stoponminbalance.onchange = function() {
        self.stop_on_min_balance = self.menu.stoponminbalance.checked;
    };
	
	this.menu.calculatesafebet.onchange = function() {
		self.calculate_safe_bet = self.menu.calculatesafebet.checked;
		self.menu.basebet.disabled = self.menu.calculatesafebet.checked;
		self.menu.safebetamount.disabled = !self.menu.calculatesafebet.checked;
	};

    // WTF is this shit below? >,.,<

    this.menu.black.onclick = function() {
        self.menu.rainbow.disabled = false;
        self.menu.black.disabled = true;
        self.menu.red.disabled = false;
        self.menu.random.disabled = false;
        self.menu.last.disabled = false;
        self.color = 'black';
        self.log('Текущий режим: Черный');
    };

    this.menu.red.onclick = function() {
        self.menu.rainbow.disabled = false;
        self.menu.black.disabled = false;
        self.menu.red.disabled = true;
        self.menu.random.disabled = false;
        self.menu.last.disabled = false;
        self.color = 'red';
        self.log('Текущий режим: Красный');
    };

    this.menu.rainbow.onclick = function() {
        self.menu.rainbow.disabled = true;
        self.menu.black.disabled = false;
        self.menu.red.disabled = false;
        self.menu.random.disabled = false;
        self.menu.last.disabled = false;
        self.color = 'rainbow';
        self.log('Текущий режим: Радугой');
    };

    this.menu.random.onclick = function() {
        self.menu.rainbow.disabled = false;
        self.menu.black.disabled = false;
        self.menu.red.disabled = false;
        self.menu.random.disabled = true;
        self.menu.last.disabled = false;
        self.color = 'random';
        self.log('Текущий режим: Случайный');
    };

    this.menu.last.onclick = function() {
        self.menu.rainbow.disabled = false;
        self.menu.black.disabled = false;
        self.menu.red.disabled = false;
        self.menu.random.disabled = false;
        self.menu.last.disabled = true;
        self.color = 'last';
        self.log('Текущий режим: Последнее выбранное');
    };

    this.menu.martingale.onclick = function() {
        self.menu.martingale.disabled = true;
        self.menu.greatmartingale.disabled = false;
        self.menu.betgreen.disabled = false;
        self.menu.dalembert.disabled = false;
        for (var i = 0; i < self.menu.hideongreen.length; i++) {
            self.menu.hideongreen[i].style.display = 'block';
        }
        self.method = 'martingale';
        self.log('Текущий режим: Мартингейл');
    };

    this.menu.greatmartingale.onclick = function() {
        self.menu.martingale.disabled = false;
        self.menu.greatmartingale.disabled = true;
        self.menu.betgreen.disabled = false;
        self.menu.dalembert.disabled = false;
        for (var i = 0; i < self.menu.hideongreen.length; i++) {
            self.menu.hideongreen[i].style.display = 'block';
        }
        self.method = 'great martingale';
        self.log('Текущий режим: Мартингейл +');
    };

    this.menu.dalembert.onclick = function() {
        self.menu.martingale.disabled = false;
        self.menu.greatmartingale.disabled = false;
        self.menu.betgreen.disabled = false;
        self.menu.dalembert.disabled = true;
        for (var i = 0; i < self.menu.hideongreen.length; i++) {
            self.menu.hideongreen[i].style.display = 'block';
        }
        self.method = 'dalembert';
        self.log('Текущий режим: Д\'аламберт');
    };

    this.menu.betgreen.onclick = function() {
        self.menu.martingale.disabled = false;
        self.menu.greatmartingale.disabled = false;
        self.menu.betgreen.disabled = true;
        self.menu.dalembert.disabled = false;
        for (var i = 0; i < self.menu.hideongreen.length; i++) {
            self.menu.hideongreen[i].style.display = 'none';
        }
        self.method = 'green';
        self.log('Текущий режим: Зеленое');
    };

    this.menu.theme.onclick = function() {
        if (self.theme === 'dark') {
            self.lightMode();
            self.theme = 'light';
            self.log('Смена на светлую тему...');
        } else {
            self.darkMode();
            self.theme = 'dark';
            self.log('Смена на тёмную тему...');
        }
    };

    setInterval(function() {
        if(!WS) {
            self.log('Повторное подключение...');
            connect();
        }
    }, 5000);
}

setTimeout(javascript:connect(), 1000);

Automated.prototype.updateBalance = function() {
    this.balance = parseInt(balance.textContent);

    if (isNaN(this.balance)) {
        this.log('Ошибка при получении баланса!');
        return false;
    }

    if (this.debug) { this.logdebug('Обновление баланса: ' + this.balance); }
    return true;
};

Automated.prototype.updateHistory = function() {
    var self = this;
    this.history = [];

    for (var i = 0; i < roll_history.childNodes.length; i++) {
        var roll = parseInt(roll_history.childNodes[i].textContent);

        if (!isNaN(roll)) {
            if (colors.green.indexOf(roll) !== -1) {
                self.history.push('green');
            } else if (colors.red.indexOf(roll) !== -1) {
                self.history.push('red');
            } else {
                self.history.push('black');
            }
        }
    }

    if (this.debug) { this.logdebug('Обновление истории: ' + this.history.map(function(value) { return value; }).join(', ')); }
    return this.history.length === 10;
};

Automated.prototype.updateStats = function() {
    this.stats.balance = parseInt(this.balance) - parseInt(this.starting_balance);
    this.menu.statistics.wins.innerHTML = this.stats.wins;
    this.menu.statistics.loses.innerHTML = this.stats.loses;
    this.menu.statistics.balance.innerHTML = this.stats.balance;
    return true;
};

Automated.prototype.updateAll = function() {
    return this.updateBalance() && this.updateHistory() && this.updateStats();
};

Automated.prototype.bet = function(amount, color) {
    var self = this;
    color = color || this.color || this.default_color;

    if (color === 'rainbow') {
        if (this.last_color) {
            color = (this.last_color === 'red' ? 'black' : 'red');
        } else {
            color = this.default_color;
        }
    } else if (color === 'random') {
        color = 'red';
        if (Math.random() > 0.5) {
            color = 'black';
        }
    } else if (color === 'last') {
        color = this.history[this.history.length - 1];
    }

    if (['green', 'red', 'black'].indexOf(color) < 0 || amount > this.balance || amount <= 0) {
        this.log('Недопустимая ставка!');
        this.last_result = 'invalid bet';
        this.waiting_for_bet = false;
        this.stop();
        return false;
    }

    if (this.balance - amount < this.min_balance) {
        this.log('Достигнут минимальный баланс!');
        this.last_result = 'reached min balance';
        if (this.stop_on_min_balance || this.balance - this.base_bet < this.min_balance) {
            this.stop();
        }
        this.waiting_for_bet = false;
        return false;
    }

    bet_input.value = amount;

    if (!bet_buttons[color].disabled) {
        var old_balance = self.balance;
        this.log('Ставка ' + amount + ' на ' + color);
        if (!self.simulation) {
            bet_buttons[color].click();
            var checker = setInterval(function() {
                if (!bet_buttons[color].disabled) {
                    clearInterval(checker);
                    setTimeout(function() {
                        if (self.updateBalance() && self.balance === old_balance) {
                            if (!self.game) { return false; }
                            self.log('Ставка отклонена, повторяем...');
                            self.bet(amount, color);
                        } else {
                            if (self.debug) { self.logdebug('Ставка принята!'); }
                            self.last_bet = amount;
                            self.bet_history.push(amount);
                            self.last_color = color;
                            self.waiting_for_bet = false;
                            return true;
                        }
                    }, 2500);
                }
            }, 1000);
        } else {
            self.bet_history.push(amount);
            self.last_bet = amount;
            self.last_color = color;
            self.waiting_for_bet = false;
            return true;
        }
    } else {
        if (!self.game) { return false; }
        self.log('Кнопка отключена, повторяем...');
        setTimeout(function() { self.bet(amount, color) }, (Math.random() * 3 + 2).toFixed(3) * 1000);
    }
};

Automated.prototype.play = function() {
    var self = this;

    if (this.game !== null) {
        if (this.debug) { this.logdebug('Пытаемся переинициализировать запуск игры!'); }
        return false;
    }

    this.game = setInterval(function() {
        var history = self.history;
        if (!self.waiting_for_bet && self.updateAll() && !history.equals(self.history)) {
            self.waiting_for_bet = true;
            if (self.last_color === null) {
                self.bet(self.base_bet);
            } else if (self.last_color === self.history[self.history.length - 1]) {
				if (self.calculate_safe_bet) {
                    self.base_bet = Math.floor(self.balance / Math.pow(2, self.safe_bet_amount + 1));
					self.menu.basebet.value = self.base_bet;
				}
                self.last_result = 'win';
                self.log('Победа!');
                self.stats.wins += 1;
                self.old_base = self.base_bet;
                self.old_method = self.method;
                if (self.old_method === 'dalembert') {
                    if (self.last_bet > self.old_base) {
                        self.bet(self.last_bet - 1);
                    } else {
                        self.bet(self.base_bet);
                    }
                } else {
                    self.bet(self.base_bet);
                }
            } else {
                self.last_result = 'lose';
                self.log('Поражение!');
                self.stats.loses += 1;
                if (self.old_method === 'martingale') {
                    self.bet(self.last_bet * 2);
                } else if (self.old_method === 'great martingale') {
                    self.bet(self.last_bet * 2 + self.old_base);
                } else if (self.old_method === 'green') {
                    var bet_value = 0;
                    if (self.bet_history[self.bet_history.length - 1] === 1) {
                        if (self.bet_history[self.bet_history.length - 2] === 1) {
                            bet_value = 2;
                        } else {
                            bet_value = 1;
                        }
                    } else {
                        bet_value = self.bet_history[self.bet_history.length - 1] + self.bet_history[self.bet_history.length - 2];
                    }
                    self.bet(bet_value, 'green');
                } else if (self.old_method === 'dalembert') {
                    self.bet(self.last_bet + 1);
                }
            }
        }
    }, 2 * 1000);

    return true;
};

Automated.prototype.start = function() {
    if (self.calculate_safe_bet) {
        self.base_bet = Math.floor(self.balance / Math.pow(2, self.safe_bet_amount + 1));
        self.menu.basebet.value = self.base_bet;
    }
    this.old_base = this.base_bet;
    this.old_method = this.method;
    if (this.updateAll()) {
        if (this.last_result === 'lose') {
            this.running = true;
            if (this.old_method === 'martingale') {
                this.bet(this.last_bet * 2);
            } else if (this.old_method === 'great martingale') {
                this.bet(this.last_bet * 2 + this.old_base);
            } else if (self.old_method === 'green') {
                var bet_value = 0;
                if (self.bet_history[self.bet_history.length - 1] === 1) {
                    if (self.bet_history[self.bet_history.length - 2] === 1) {
                        bet_value = 2;
                    } else {
                        bet_value = 1;
                    }
                } else {
                    bet_value = self.bet_history[self.bet_history.length - 1] + self.bet_history[self.bet_history.length - 2];
                }
                self.bet(bet_value, 'green');
            } else if (self.old_method === 'dalembert') {
                self.bet(self.last_bet + 1);
            }
            this.play();
        } else {
            this.running = true;
            this.bet(this.base_bet);
            this.play();
        }
    }
    this.menu.abort.disabled = false;
    this.menu.stop.disabled = false;
    this.menu.start.disabled = true;
};

Automated.prototype.stop = function(abort) {
    var self = this;
    if (abort) { this.last_result = 'abort'; }
    this.stats.balance = parseInt(this.balance) - parseInt(this.starting_balance);
    setTimeout(function() {
        clearInterval(self.game);
        self.game = null;
        self.running = false;
        self.menu.abort.disabled = true;
        self.menu.stop.disabled = true;
        self.menu.start.disabled = false;
    }, 1); // Next tick
};

Automated.prototype.darkMode = function() {
    var style;
    var css = 'body{background-color:#191919;color:#888}.navbar-default{background-color:#232323;border-color:#454545}#sidebar{background-color:#191919;border-color:#202020}.side-icon.active,.side-icon:hover{background-color:#202020}.side-icon .fa{color:#454545}.well{background:#232323;border-color:#323232;color:#888}#pullout{background-color:#191919;border-color:#323232}.form-control{background-color:#323232;border-color:#454545}.divchat{background-color:#323232;color:#999;border:none}.chat-link,.chat-link:hover,.chat-link:active{color:#bbb}.panel{background-color:#323232}.panel-default{border-color:#454545}.panel-default>.panel-heading{color:#888;background-color:#303030;border-color:#454545}.my-row{border-color:#454545}.list-group-item{border-color:#454545;background-color:#323232}.btn-default{border-color:#454545;background:#323232;text-shadow:none;color:#888;box-shadow:none}.btn-default:hover,.btn-default:active{background-color:#282828;color:#888;border-color:#454545}.btn-default[disabled]{border-color:#454545;background-color:#353535}.input-group-addon{background-color:#424242;border-color:#454545;color:#888}.progress{color:#bbb;background-color:#323232}.navbar-default .navbar-nav>li>a:focus,.navbar-default .navbar-nav>li>a:hover{color:#999}.navbar-default .navbar-nav>.open>a,.navbar-default .navbar-nav>.open>a:focus,.navbar-default .navbar-nav>.open>a:hover{color:#888;background-color:#323232}.dropdown-menu{background-color:#252525}.dropdown-menu>li>a{color:#888}.dropdown-menu>li>a:focus,.dropdown-menu>li>a:hover{background-color:#323232;color:#999}.dropdown-menu .divider{background-color:#454545}.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{background-color:#404040;opacity:.5}';
    style = document.getElementById('automated-style');
    if (!style) {
        var head;
        head = document.getElementsByTagName('head')[0];
        if (!head) { return; }
        style = document.createElement('style');
        style = document.createElement('style');
        style.type = 'text/css';
        style.id = 'automated-style';
        style.innerHTML = css;
        head.appendChild(style);
    }
    style.innerHTML = css;
};

Automated.prototype.lightMode = function() {
    var style = document.getElementById('automated-style');
    style.innerHTML = '';
};

Automated.prototype.log = function(message) {
    chat('alert', '[Бот] ' + message);
};

Automated.prototype.logdebug = function(message) {
    chat('italic', '[Бот] ' + message);
};

var automated = new Automated();