Skip to content

Instantly share code, notes, and snippets.

@uhtred
Created November 29, 2012 22:56
Show Gist options
  • Save uhtred/4172479 to your computer and use it in GitHub Desktop.
Save uhtred/4172479 to your computer and use it in GitHub Desktop.
AutoBets: Mukirana
// Mukirana.com.br
// @example TrackMukirana.start({ max_price: 'R$ 30,00', interval: 500, auction_id: '', seconds_limit: '02', bets_limit: 20, debug: true });
var TrackMukirana = (function(){
var auction_id = '',
tmpTrack,
betData = {},
trackOptions = {},
bets = 0,
user = 'drfranca';
function getPrice(){
if( !$price ) {
var $price = document.querySelector('#current_price_auction_'+ trackOptions.auction_id);
}
return $price.innerHTML;
}
function getSec(){
if( !$sec ) {
var $sec = document.querySelector('#current_time_auction_'+ trackOptions.auction_id);
}
if( !$sec ) {
stop();
}
return $sec.innerHTML;
}
function getLast(){
if( !$last ) {
var $last = document.querySelector('#current_username_auction_'+ trackOptions.auction_id);
}
return ( $last ? $last.innerHTML : 'nobody' );
}
function pressBetBtn(){
if( !$betBtn ){
var $betBtn = document.querySelector('#submit_auction_'+ trackOptions.auction_id);
}
$betBtn.click();
}
function bet(){
bets++;
console.log('Bet!', { sec: getSec(), price: getPrice(), bets: bets });
if( !trackOptions.debug ) {
console.log('Real Bet!');
pressBetBtn();
}
}
function updatePageTitle(){
document.title = 'Bets( '+ bets +' )';
}
function start( options ) {
if( options ) {
trackOptions = options;
}
reset();
tmpTrack = window.setInterval(function(){
updatePageTitle();
console.log('Bets: '+ bets);
if( bets <= trackOptions.bets_limit && getSec() == trackOptions.seconds_limit && getPrice() != trackOptions.max_price && getLast() != user ) {
bet();
}
}, trackOptions.interval);
}
function reset(){
$sec = $price = $btnBet = null;
stop();
}
function stop(){
if( tmpTrack ) {
clearInterval(tmpTrack);
}
}
return { getPrice: getPrice, getSec: getSec, bet: bet, start: start, stop: stop, getLast: getLast };
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment