Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2165
  • Last Modified:

Javascript pause before next execution help

Hello everyone,

I created a script for a game and basically it goes through and goes to the add request page for myspace.  Then all the user has to do is click the button and finish a captcha after 5 adds.  What I did was went down a pre-made list of id's for this and had the script wait 30 seconds in-between each page.  However, it seems to be rather consuming and will completely halt firefox while until it finishes reading the script.  Then it'll execute.  Is there a way to make a better pause function that won't be so hard on browsers?
<script type="text/javascript">
function open_window(url) {
	mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1000,height=1400');
}
function pause(millis) {
var date = new Date();
var curDate = null;
do { 
curDate = new Date(); 
}
while(curDate-date < millis);
} 
</script>
</head>
 
<BR><BR>
Pop-ups must be enabled.  This script will go through every Silver-Mob member.  Please go through and invite everyone into your friend list and mob.  Captcha's typically happen every 5 adds, so be aware.
<script> 
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=417501204');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=107831660');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=54575935');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=11412696');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=169412488');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=403745266');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=138121891');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=73199523');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=406204413');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=184499963');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=91247815');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=65981723');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=55955177');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=204988332');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=133698825');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=396135369');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=121214428');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=320969254');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=204971887');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=426039187');
pause(30000);
open_window('http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=134224164');
</script>

Open in new window

0
TurboBorland
Asked:
TurboBorland
  • 4
  • 3
1 Solution
 
captaincagemenCommented:
setInterval !
0
 
captaincagemenCommented:
Or if you want it only to happen once use this:
setTimeout('alert(\'5 seconds passed!\')', 5000)"

Open in new window

0
 
TurboBorlandAuthor Commented:
I have tried getting setTimeout() to work, however I was not successful.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
captaincagemenCommented:
Very strange, I just tested it myself to be sure (see code snippet), and its working perfect for me
<html>
<head>
</head>
<body>
<script type="text/javascript">
setTimeout('alert(\'5 seconds passed!\')', 5000);
</script>
</body>
</html>

Open in new window

0
 
TurboBorlandAuthor Commented:
I mean I was unable to get my script to work with the function.  Probably on how I used it.  However, I need the pause to be performed after every open_window function is performed.
0
 
captaincagemenCommented:
I changed your script, its working now!
<html>
<head>
</head>
<body>
<script type="text/javascript">
 
var c = 0;
var urls = new Array();
urls[0] = 'http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=417501204';
urls[1] = 'http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=107831660';
urls[2] = 'http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=54575935';
urls[3] = 'http://collect.myspace.com/index.cfm?fuseaction=invite.addfriend_verify&friendID=11412696';
 
function startWindowPopups() {
  
  if(urls[c] != null) {
     open_window(urls[c]);
     c++;
     setTimeout('startWindowPopups()', 30000);
  }
  
  
}
 
function open_window(url) {
        mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1000,height=1400');
}
 
startWindowPopups();
</script>
</head>
 
<BR><BR>
Pop-ups must be enabled.  This script will go through every Silver-Mob member.  Please go through and invite everyone into your friend list and mob.  Captcha's typically happen every 5 adds, so be aware.
</script>
</body>
</html>

Open in new window

0
 
TurboBorlandAuthor Commented:
Exactly what I needed.  Works like a charm. ;)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now