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

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
crippplertd
  • 67
  • 2
  • 7
  • Note that you can open up Firefox's error console (***Ctrl+Shift+J***) to see errors that code like this will throw. – Brock Adams Apr 29 '13 at 06:24

1 Answers1

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;
}
Community
  • 1
  • 1
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • you're my hero :) - as you can tell I don't program alot - lol I research to the best of my ability but dont understand alot of the varibles and what not. – crippplertd Apr 29 '13 at 06:37
  • Glad to help. :) Keep in mind that error console. If the error message doesn't help you figure out the problem, including it in your question will get you more/faster/better response. – Brock Adams Apr 29 '13 at 07:01