function begin() { let settings = JSON.parse($("#settings").html()); let status = $("#status").html(); //console.log("msg"); //console.log(settings); //console.log(status); $("#settings").remove(); $("#status").remove(); if(status=='ON') { setInterval(() => { if (typeof remainTime !== "undefined") { remainTime = 0; } }, 3000); } } function dom_ready() { //console.log("checking..."); if($("#settings").length>0) { clearInterval(myInterval); begin(); } } myInterval = setInterval(() => { dom_ready(); }, 100);