I am making a script for a betting website to Automate it but my script is not working.
I want to auto click the buttons with IDs #box38
, #playBtn
, #resetStats
. I also want that when I lose, increase the bet to 0.00000004
and when I win, reset it to 0.00000001
but that is not working either and I don't know why.
There is 2 text with IDs #currentWins
and #currentLossess
. Why is that not working?
I just want these to work:
The code is just not working at all. I'm also using TamperMonkey and I haven't forgotten to add the latest version of jQuery
HTML:
three buttons:
<a id="resetStats">RESET</a>
<div class="box" id="box38" onclick="Game.play(38); return false;"></div>
<button class="btn blue" id="playBtn" onclick="Game.play(0); >LET'S GO!</button>
and 2 text written in div tags:
<div class="input green" id="currentWins">0</div>
<div class="input red" id="currentLosses">0</div>
function doit() {
window.setInterval(event1, 2000);
$("#playBtn").click();
function event1() {
$("#box38").click();
(function() {
$("#resetStats").click();
$("#playBtn").click();
setTimeout(arguments.callee, 5000);
})();
}
function winloss() {
var wins = $("div#currentWins").text();
var loss = $("div#currentLosses").text();
if (wins == 1) {
document.getElementById("betAmount").value = "0.00000001";
doit();
} else if (loss == 1) {
document.getElementById("betAmount").value = "0.00000004";
doit();
}
}
}
After some investigation, I found out that there were multiple problems.
doit
was never called.winloss
was never called.doit
after finishing winloss
, even though, looking at your code, you intended to click #box38
once.$("#playBtn").click
even though it was already automatically looped in the event1
private function.#betAmount
with the value
property.#resetStats
as an <a>
, but it's most probably a button.So hopefully I read your code and question correctly, and I refactored it:
function doit() {
event1()
function event1() {
$("#box38").click();
winloss();
(function() {
winloss()
$("#resetStats").click();
$("#playBtn").click();
setTimeout(arguments.callee, 5000);
})();
}
function winloss() {
const lost = $("div#currentLosses").text() != 0
if (lost) {
document.getElementById("betAmount").value = "0.00000004";
} else {
document.getElementById("betAmount").value = "0.00000001";
}
}
}
doit()
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="resetStats" onclick="$('div#currentWins').text(0);$('div#currentLosses').text(0)">RESET</button>
<script>
let Game = {
play: function(a) {
if (a == 38) {
return false
}
setTimeout(function() {
let wins = $("div#currentWins").text()
let losses = $("div#currentLosses").text()
if (Math.random() > 0.5) {
wins++
} else {
losses++
}
$("div#currentWins").text(wins)
$("div#currentLosses").text(losses)
}, 4000) //Simulating API delay
}
}
</script>
<div class="box" id="box38" onclick="Game.play(38); return false;"></div>
<button class="btn blue" id="playBtn" onclick="Game.play(0);">LET'S GO!</button>
<div class="input green" id="currentWins">0</div>
<div class="input red" id="currentLosses">0</div>
<input id="betAmount" value="0">