Skip to content

Instantly share code, notes, and snippets.

@bitkominer
Forked from nxmad/Yobit.js
Last active February 1, 2018 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitkominer/9ae8250ee21efe836a35e2c8c9a37ff0 to your computer and use it in GitHub Desktop.
Save bitkominer/9ae8250ee21efe836a35e2c8c9a37ff0 to your computer and use it in GitHub Desktop.
if (window._bot != undefined) {
// alert('Bot added before, if something goes wrong try reload the page')
}
window._bot = true
window._martingale = 1.65
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._amount = (window._amount * 0.75).toFixed(8)
if (window._amount > (parseFloat(data.bal)*0.0001)) {
log('Won during high stake, back to initial stake')
window._amount = (parseFloat(data.bal)*0.00001000).toFixed(8)
}
if (window._amount < (1*0.00000010).toFixed(8)){
window._amount = (1*0.00000010).toFixed(8)
}
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)*0.1)) {
log('Oops! Recovery steps failed, trying to do split recovery')
window._amount = (window._amount * 0.5).toFixed(8)
if (window._amount < (1*0.00000010).toFixed(8)){
window._amount = (1*0.00000010).toFixed(8)
}
}
}
$('.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