I have a script that changes some values and clicks some buttons in a browser. I'm looking for a way to pause the execution of the code for x seconds without making the browser lag out. I'm using Firefox and I paste this script into its console. I'm aware of the setTimeout() function. However, this function doesn't stop executing the code, but rather waits x seconds till executing it. I'm looking for a complete solution that's similar to Python's time.sleep() function and pauses the execution of the code completely.
var init = 0.01
var start = init
var $odds = $("#oddsOverUnder")
var $button = $("#roll")
var $bet = $("#bet")
function roll(){
    $bet.val(start)
    $button.click()
    //i want to pause the execution of the code here//
    $button.click()
    //and here//
    refreshIntervalId=setInterval(roll2, 2000)}
function roll2(){
    var tr = document.querySelector("#myBetsTable tr:nth-child(2)")
    var cls = tr.getAttribute('class')
    if (cls === 'success'){
        start = init
        $bet.val(start)}
    else{
        start = start * 2
        $bet.val(start)
        $odds.click()}
clearInterval(refreshIntervalId)
roll()}
roll()
 
     
     
    