hello im trying to make an extension for a gambling website its a roullete autobetter . i have done the logic ( js code) and its working fine . but im facing some problems when i load the extension i receive some errors that i dont understand . and the most important piece code does not run for some reason some times i does not show some parts of the ui . sometimes the alignments get messed up . its just so inconsistent . these some screenshots of the errors i receive
this the code i write some text above the part that is not executing for some reason (i copy pasted the same part in js injector extension and its working fine so the logic is right) in this part i use a self declare function with setinterval
const box = document.createElement("div");
const f =document.getElementsByClassName("roulette-header")[0]
f.appendChild(box);
box.id = "ExtensionBox";
document.getElementById("ExtensionBox").style.display = "flex"
document.getElementById("ExtensionBox").style.marginTop = "5%"
document.getElementById("ExtensionBox").style.background= "#1c1c22";
document.getElementById("ExtensionBox").style.height = "180px"
document.getElementById("ExtensionBox").style.width = "400%"
document.getElementById("ExtensionBox").style.borderRadius = "5px"
const BaseBet = document.createElement("h1")
BaseBet.innerHTML = "Base Bet"
BaseBet.style.color = "white"
BaseBet.style.position = "relative"
BaseBet.style.left = "40%"
BaseBet.style.fontSize = "2rem"
BaseBet.style.marginTop = "10px"
box.appendChild(BaseBet)
const BasBetInput = document.createElement("input")
BasBetInput.type = "number"
BasBetInput.id = "BasBetInput"
BasBetInput.style.position = "relative"
BasBetInput.style.left = "32%"
BasBetInput.style.fontSize = "1.5rem"
BasBetInput.style.width = "25%"
BasBetInput.style.background = "#2d2d35"
BasBetInput.style.marginTop = "42px"
BasBetInput.placeholder = " 10 recomended "
BasBetInput.style.borderRadius = "5px"
box.appendChild(BasBetInput)
const BaseBet2 = document.createElement("h1")
BaseBet2.innerHTML = "Target Balance"
BaseBet2.style.color = "white"
BaseBet2.style.position = "relative"
BaseBet2.style.left = "7%"
BaseBet2.style.top = "40%"
BaseBet2.style.fontSize = "2rem"
box.appendChild(BaseBet2)
const BasBetInput2 = document.createElement("input")
BasBetInput2.type = "number"
BasBetInput2.id = "BasBetInput2"
BasBetInput2.style.position = "relative"
BasBetInput2.style.left = "-6%"
BasBetInput2.style.fontSize = "1.5rem"
BasBetInput2.style.width = "25%"
BasBetInput2.style.background = "#2d2d35"
BasBetInput2.style.marginTop = "130px"
BasBetInput2.placeholder = " once reached bot will stop "
BasBetInput2.style.borderRadius = "5px"
box.appendChild(BasBetInput2)
const Redbox = document.createElement("div");
f.appendChild(Redbox)
Redbox.id = "redbox"
document.getElementById("redbox").style.display = "flex"
document.getElementById("redbox").style.marginTop = "4%"
document.getElementById("redbox").style.background= "#c8354e";
document.getElementById("redbox").style.height = "180px"
document.getElementById("redbox").style.width = "110%"
document.getElementById("redbox").style.borderRadius = "5px"
Redbox.style.position = "relative"
Redbox.style.right = "71%"
Redbox.style.whiteSpace = "nowrap"
const balanc = document.createElement("h1")
balanc.innerHTML = "Your Starting balance :"+document.getElementById('balance').innerHTML
Redbox.appendChild(balanc)
balanc.id = "balanc"
document.getElementById("balanc").style.color = "white"
document.getElementById("balanc").style.fontSize = "2.5rem"
document.getElementById("balanc").style.marginLeft = "10px"
const message = document.createElement("h2")
message.style.color = "white"
message.innerHTML = " Your can Survive :"
message.style.fontSize = "2.5rem"
message.style.position = "relative"
message.style.top = "75px"
message.style.right = "300px"
message.style.textAlign = "center"
message.id = "message"
Redbox.appendChild(message)
document.getElementById("message").style.fontWeight = "300"
clearbutton = document.createElement("button")
clearbutton.type = "reset"
clearbutton.innerHTML = "reset"
clearbutton.style.height = "50px"
clearbutton.style.width = "10%"
clearbutton.style.color = "white"
clearbutton.style.borderRadius = "5px"
clearbutton.style.fontSize = "1.5rem"
clearbutton.style.background = "#2d2d35"
clearbutton.style.borderColor = "#2d2d35"
clearbutton.style.margin="10px"
clearbutton.style.position = "relative"
clearbutton.style.top="55px"
clearbutton.style.left="16.6%"
box.appendChild(clearbutton)
clearbutton1 = document.createElement("button")
clearbutton1.style.boxShadow = "none"
clearbutton1 = document.createElement("button")
clearbutton1.innerHTML = "indurance"
clearbutton1.style.height = "50px"
clearbutton1.style.width = "10%"
clearbutton1.style.color = "white"
clearbutton1.style.borderRadius = "5px"
clearbutton1.style.fontSize = "1.5rem"
clearbutton1.style.background = "#2d2d35"
clearbutton1.style.borderColor = "#2d2d35"
clearbutton1.style.margin="-30px"
clearbutton1.style.position = "relative"
clearbutton1.style.top="37px"
clearbutton1.style.left="102px"
box.appendChild(clearbutton1)
StartButton = document.createElement("button")
StartButton.id="sb"
box.appendChild(StartButton)
document.getElementById("sb").innerHTML = "Start Bot"
document.getElementById("sb").style.background = "#c8354e"
document.getElementById("sb").style.width = "10%"
document.getElementById("sb").style.height = "50px"
document.getElementById("sb").style.color = "white"
StartButton.style.margin="10px"
StartButton.style.marginTop="122px"
document.getElementById("sb").style.borderColor = "#c8354e"
document.getElementById("sb").style.borderRadius = "5px"
document.getElementById("sb").style.fontSize = "1.5rem"
clearbutton.addEventListener("click",function(){
document.getElementById("BasBetInput2").value = "";
document.getElementById("BasBetInput").value = "";
})
losses = 1;
clearbutton1.addEventListener("click",function(){
balance= document.getElementById('balance').innerHTML;
balance = parseInt(balance.replace(",",""));
if (balance > 120){
bt=document.getElementById("BasBetInput").value;
losses = 1;
do{
bt = bt*2
balance = balance-bt
losses = losses+1
}while (!(bt > balance))
document.getElementById("message").innerHTML = " Your can Survive :"+" "+losses +" "+ "Losses"
}
})
document.getElementById("sb").addEventListener("click",function(){
balance= document.getElementById('balance').innerHTML;
balance = parseInt(balance.replace(",",""));
bt=document.getElementById("BasBetInput").value;
TargetBalance=document.getElementById("BasBetInput2").value;
document.getElementById('bet-input-r').value = bt ;
bc="black";
if (bc == "red" ){
document.getElementById('roulette-btn-red').click();
}else{
document.getElementById('roulette-btn-black').click();
}
setInterval(function(){
// code here does not excute for some reason
balance= document.getElementById('balance').innerHTML;
balance = parseInt(balance.replace(",",""));
if (TargetBalance>balance){
l=((document.getElementsByClassName("roulette-past-queue--previous-rolls-container horizontal-scroll")[0].innerText).length);
f = document.getElementsByClassName("roulette-past-queue--previous-rolls-container horizontal-scroll")[0].innerText;
number = f.substring(f.lastIndexOf("\n"),l);
number = parseInt(number.replace(" ",""));
if (number >= 1 && number <= 7){
LastResult = "red";
};
if (number >= 8 && number <= 14){
LastResult = "black";
};
if (number == 0){
LastResult = "green";
};
if(LastResult == bc){
if (bc == "red"){
document.getElementById('bet-input-r').value = bt ;
document.getElementById('roulette-btn-red').click();
}else{
document.getElementById('bet-input-r').value = bt ;
document.getElementById('roulette-btn-black').click();
};
};
if(LastResult !== bc){
if (bc == "red"){
document.getElementById('bet-btn-double-r').click();
document.getElementById('roulette-btn-black').click();
bc = "black"
}else{
document.getElementById('bet-btn-double-r').click();
document.getElementById('roulette-btn-red').click();
bc = "red"
};
}
}
},32000 );
})
manifest file :
{
"name": "CSGO500 Roullete Autobetter",
"description": "This is a csgo500 roullete strategy autobetter",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [
{
"js": ["foreground.js"],
"matches": ["https://csgo500.com/roulette"]
}
]
}