Last active
July 31, 2018 05:33
-
-
Save nxmad/cc688d4dfb4d19a8686650dadb9cc4fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (window._bot != undefined) { | |
// alert('Bot added before, if something goes wrong try reload the page') | |
} | |
window._bot = true | |
window._martingale = 2.05 | |
window._variant = Math.random() >= 0.5 ? 1 : 0 | |
// window._variants = ['Roll < 49', 'Roll > 51'] | |
function resolve(data) { | |
if (typeof data === "object") { | |
if (data.result == "OK") { | |
if (data.win == "1") { | |
if (window._tries > 0) { | |
log('Lost series ended up. Balance is ' + data.bal) | |
} else { | |
log('Won! ' + 'Balance is ' + data.bal) | |
} | |
window._amount = window._base | |
window._tries = 0 | |
switchBet() | |
if (window._stopAfterWon == true) { | |
stop() | |
} | |
} else { | |
window._tries += 1 | |
window._amount = ((window._tries == 1 ? 3 : 2) * window._amount).toFixed(8) | |
if (window._tries % 3 == 0) { | |
switchBet() | |
} | |
log('Lost!') | |
if (window._amount > parseFloat(data.bal)) { | |
log('Oops! Something gone wrong :( ' + ' Trying to bet' + window._amount + ' but we have only ' + data.bal) | |
stop() | |
} | |
} | |
$('.bet').val(window._amount) | |
var so = $("select[name=currency] option:selected").html(); | |
var re = /([^\-]+?- )[0-9.]+?( [a-zA-Z0-9]+)/g; | |
var sn = so.replace(re, "$1" + data.bal + "$2"); | |
$("select[name=currency] option:selected").html(sn).trigger("chosen:updated"); | |
if (window._stop == true) { | |
return; | |
} | |
setTimeout(roll, window._interval) | |
return; | |
} | |
if (data.error == 1) { | |
setTimeout(roll, 20e3) | |
} | |
log('Server error', 'warn') | |
return; | |
} | |
log('ERROR: ' + data.error) | |
} | |
function log(message, type) { | |
if (type == undefined) { | |
type = 'log' | |
} | |
console[type]('[Dice Bot]: ' + message) | |
} | |
function roll() { | |
$.ajax({ | |
url: "/ajax/system_dice.php", | |
cache: false, | |
type: "POST", | |
data: { | |
method: "dice_play", | |
csrf_token: $("#csrf_token").val(), | |
locale: 'ru', | |
currency: window._currency, | |
bet: window._amount, | |
type: window._variant | |
}, | |
dataType: "json", | |
success: resolve, | |
error: function() { | |
log('Network error', 'warn') | |
setTimeout(roll, 30e3) | |
} | |
}); | |
} | |
function stop() { | |
window._stop = true | |
log('BOT STOPPED', 'warn') | |
} | |
function stopAfterWon() { | |
window._stopAfterWon = true | |
log('Bot will stop after 1st win', 'warn') | |
} | |
function switchBet() { | |
window._variant = Math.abs(window._variant - 1) | |
} | |
function start(interval) { | |
window._base = $('.bet').val() | |
window._stop = false | |
window._stopAfterWon = false | |
window._tries = 0 | |
window._interval = 1e3 // 500ms default interval | |
window._amount = window._base | |
window._currency = $(".dice_page select[name=currency]").val().trim() // 1 - BTC, 40001 - ETH, 50001 - USD | |
roll() | |
log('Bot is started', 'warn') | |
} | |
let section = $('.dice_htable > tbody td:last') | |
section.html('') | |
$('<input />', { | |
id: 'bot_start', | |
type: 'button', | |
value: 'Start', | |
}).appendTo(section).click(start) | |
$('<input />', { | |
id: 'bot_stop', | |
type: 'button', | |
style: 'background-color: #f4a35e', | |
value: 'Stop', | |
}).appendTo(section).click(stop) | |
$('<input />', { | |
id: 'bot_stop', | |
type: 'button', | |
style: 'background-color: #90d8b4', | |
value: 'After win', | |
}).appendTo(section).click(stopAfterWon) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Balatsky. Please tell me how do i use your script?