Created
November 15, 2018 15:07
-
-
Save veritstudio/089784e11a0cc183f6be14075a718d81 to your computer and use it in GitHub Desktop.
Auction bot
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
var auctioner = (function ($) { | |
var module = {}; | |
module.deuterButton = $('.js_sliderDeuteriumMax'); | |
module.deuterInput = $(''); | |
module.submitButton = $('.right_content a.pay'); | |
module.maxAmount = 500000; | |
module.currentAmount = $('.div_trader .currentSum'); | |
module.currentPlayer = $('.div_trader .currentPlayer'); | |
module.init = function () { | |
module.listenAuction(); | |
}; | |
module.setHigherBid = function () { | |
module.deuterButton.click(); | |
setTimeout(function() { | |
module.submitButton.click(); | |
module.listenAuction(); | |
}, 1000); | |
}; | |
module.listenAuction = function () { | |
let time = module.calculateListenTime(); | |
setTimeout(function() { | |
if (!module.isUnderValue()) { | |
console.log('The bid is too high! \n' + new Date()); | |
return; | |
} | |
if (!($('.noAuctionOverlay').css('display') == 'none')) { | |
console.log('The auction has been closed \n' + new Date()); | |
return; | |
} | |
if (module.isWinning()) { | |
console.log('You are winning! \n' + new Date()); | |
module.listenAuction(); | |
} else { | |
console.log('You took the bid! \n' + new Date()); | |
module.setHigherBid(); | |
} | |
}, time); | |
}; | |
module.isWinning = function () { | |
return module.currentPlayer.text() == 'osocz'; | |
}; | |
module.isUnderValue = function () { | |
return module.getCurrentBid() < module.maxAmount; | |
}; | |
module.calculateListenTime = function () { | |
let time = $('.auction_info b').text().replace(/\D/g,''); | |
console.log('regex ', time); | |
let timeToCheck = 240000; | |
if (time < 26) { | |
timeToCheck = 120000; | |
} | |
if (time < 13) { | |
timeToCheck = 60000; | |
} | |
if (time < 7) { | |
timeToCheck = Math.random() * (3000 - 1500) + 1500; | |
} | |
console.log('Waiting ' + timeToCheck + 's to next check'); | |
return timeToCheck; | |
}; | |
module.getCurrentBid = function () { | |
let current = module.currentAmount.text().replace(/\D/g,''); | |
console.log(current); | |
return current; | |
}; | |
return module; | |
})(jQuery); | |
auctioner.init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment