Last active
July 12, 2018 12:58
-
-
Save HiveSolution/c27138c7f6330c2cae954ca0a03170e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ==UserScript== | |
// @name Auto-Gamble | |
// @namespace autoGamble | |
// @include https://csgopolygon.com/ | |
// @version 1.3 | |
// @grant none | |
// ==/UserScript== | |
$(document).on('ready', () => { | |
console.log('ready'); | |
$($('.roulette').find('.well.text-center')[0]).append(` | |
<div class="form-group"> | |
<div class="input-btn"> | |
<button type="button" class="btn btn-default" id="gmStart">Start</button> | |
<button type="button" class="btn btn-danger" id="gmStop">Stop</button> | |
</div> | |
</div> | |
`); | |
}); | |
let firstRun = true; | |
let runGamble; | |
let hasBet = false; | |
let initAmount = 2; | |
$('#betAmount').val(initAmount); | |
let currenAmount = initAmount; | |
let currentColor = 'red'; | |
$(document).on('click', '#gmStart', () => { | |
startGamble(); | |
}); | |
$(document).on('click', '#gmStop', () => { | |
stopGamble(); | |
}); | |
function startGamble () { | |
runGamble = setInterval(curRunning, 1000); | |
} | |
function stopGamble () { | |
clearInterval(runGamble); | |
firstRun = true; | |
currenAmount = initAmount; | |
} | |
function curRunning () { | |
const rollText = $('#banner').text(); | |
let allowBet = false; | |
if (rollText.indexOf('Rolling') >= 0) { | |
allowBet = true; | |
} else { | |
allowBet = false; | |
hasBet = false; | |
} | |
if (!hasBet && allowBet) { | |
bet(); | |
} | |
} | |
function bet () { | |
if (!firstRun) { | |
let lastWon = ''; | |
if ( $($('#past').find('.ball')[$('#past').find('.ball').length-1]).hasClass('ball-8') ) { | |
lastWon = 'black'; | |
} else if ( $($('#past').find('.ball')[$('#past').find('.ball').length-1]).hasClass('ball-1') ) { | |
lastWon = 'red'; | |
} | |
if (lastWon === currentColor) { | |
console.log('YAY! We won! 🐱 this:', currenAmount*2); | |
currenAmount = initAmount; | |
} else { | |
console.log('Nye...we lost...😞') | |
currenAmount = currenAmount*2; | |
} | |
} else { | |
firstRun = false; | |
initAmount = Number($('#betAmount').val()); | |
} | |
hasBet = true; | |
$('#betAmount').val(currenAmount); | |
currentColor = randomColor(); | |
if (currentColor === 'red') { | |
console.log('Pressing Red-Button with:', currenAmount); | |
$('.btn.btn-danger.btn-lg.btn-block.betButton').click(); | |
} else if (currentColor === 'black') { | |
console.log('Pressing Black-Button with:', currenAmount); | |
$('.btn.btn-inverse.btn-lg.btn-block.betButton').click(); | |
} | |
} | |
function randomColor () { | |
const colors = ['red', 'black']; | |
return colors[Math.floor(Math.random() * colors.length)]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment