Solved

Javascript pause before next execution help

Posted on 2009-03-31
7
2,159 Views
Last Modified: 2012-05-06
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
Comment
Question by:TurboBorland
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 2

Expert Comment

by:captaincagemen
ID: 24034225
setInterval !
0
 
LVL 2

Expert Comment

by:captaincagemen
ID: 24034234
Or if you want it only to happen once use this:
setTimeout('alert(\'5 seconds passed!\')', 5000)"

Open in new window

0
 
LVL 4

Author Comment

by:TurboBorland
ID: 24034257
I have tried getting setTimeout() to work, however I was not successful.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:captaincagemen
ID: 24034325
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
 
LVL 4

Author Comment

by:TurboBorland
ID: 24034351
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
 
LVL 2

Accepted Solution

by:
captaincagemen earned 250 total points
ID: 24034451
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
 
LVL 4

Author Closing Comment

by:TurboBorland
ID: 31565089
Exactly what I needed.  Works like a charm. ;)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question