1

Can't seem to get my Random # to work at all - code won't execute :(

function getRandomInt (5000, 10000) {
return Math.floor(Math.random() * (10000 - 5000 + 1)) + 5000;
}

setTimeout(Greasemonkey_main, getRandomInt);

function Greasemonkey_main () {
unsafeWindow.submitform(0);
unsafeWindow.submitform(1);
unsafeWindow.submitform(2);
unsafeWindow.submitform(3);
}

Thanks

4

1 回答 1

0

That getRandomInt() has syntax error(s). Use the standard version of that function!

So the code would become:

setTimeout (Greasemonkey_main, getRandomInt (5000, 10000) );

function Greasemonkey_main () {
    unsafeWindow.submitform(0);
    unsafeWindow.submitform(1);
    unsafeWindow.submitform(2);
    unsafeWindow.submitform(3);
}

function getRandomInt (min, max) {
    return Math.floor (Math.random () * (max - min + 1) ) + min;
}
于 2013-04-29T06:18:47.603 回答