Even if you use Math.random in setInterval, it will only register once with a specific random value.
There are two options:
- , ( clearInterval )
- x ms , , .
Eg. :
setInterval(function() {
if (Math.random() > 0.8)
$( "[id^='hand_'].handIcon").trigger('click');
}, 200);
200 , 0,8 , , 250 , . , .
, (rs):
let action = () => $( "[id^='hand_'].handIcon").trigger('click');
let old, register = () => {
if (old) clearInterval(old);
old = setInterval(() => {
action();
register();
}, 32756 + 3000*Math.random() - 1500)
};
register();