Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding

Reply
 
LinkBack Thread Tools
Old 10-03-09   #1 (permalink)
PC Gamer
 
nachosanchezz's Avatar
 
intel nvidia

Join Date: Jan 2009
Location: Christchurch, New Zealand
Posts: 466

Rep: 19 nachosanchezz Unknown
Unique Rep: 18
Trader Rating: 0
Default Help with JavaScript for Greasemonkey

I want to write a java script for Grease Monkey so that it will load a specific address in a loop, and have a delay of a random length of time between, say, 10-20 minutes.

Can anyone please tell me how to do this, and possibly explain what each part of the script does.

Thanks!!

EDIT: Essentially what I need is: javascript commands to load a url, to wait for a certain amount of time, to generate a random number, and to loop the script? I have next to no knowledge of how this is suppose to work, so please tell me if any part of my question doesn't make sense.

System: My PC
CPU
E6420 - lapped
Motherboard
Asus P5Q
Memory
2x1GB Kingston DDR2-800
Graphics Card
XFX 8600GT XXX (4850 soon)
Hard Drive
WD 250GB
Sound Card
Onboard
Power Supply
CM Silent Pro M600 600W
Case
XG Sidewinder II
CPU cooling
Lapped TR Ultima-90 w/ Scythe Kama PWM 120mm
OS
Windows 7 Pro x64 RTM
Monitor
Viewsonic 19" @ 1280x1024

Last edited by nachosanchezz : 10-03-09 at 09:06 AM
nachosanchezz is offline   Reply With Quote
Old 10-03-09   #2 (permalink)
Overclocker in Training
 
darius_m5's Avatar
 
intel ati

Join Date: Sep 2008
Location: Toronto, Ontario
Posts: 104

Rep: 19 darius_m5 Unknown
Unique Rep: 16
Trader Rating: 0
Default

Here's something I just wrote.

You choose the URL's you want in the array, then it will randomly load them.

The timeout is set to 600000 Miilliseconds (10 minutes).

Code:
// ==UserScript==
// @name           Random Url's
// @namespace      http://userscripts.org
// @include        *
// ==/UserScript==

//declare variables
var rand1,rand2;

//URL array, add as many as you want.
var urls=['http://google.com','http://youtube.com','http://overclock.net']

//set rand2 to a random number between 0 and 600000 milliseconds
rand2=Math.floor(Math.random()*600000);

//Tell browser to load the load_url function after the random time (rand2)
window.setTimeout(load_url,rand2);

//And here's the function that changes the page
function load_url(){
        //get a random number to choose a random url
	rand1=Math.floor(Math.random()*urls.length);
        //make the page go to the random url
	location.href=urls[rand1];
	}
__________________
System: CM HAF 932
CPU
E8400
Motherboard
P5Q-Pro
Memory
OCZ 2x2GB PC2-8500
Graphics Card
Sapphire 4850
Hard Drive
2xWD 320GB Caviar
Power Supply
Enermax Infiniti 720W
Case
CM HAF 932
CPU cooling
OCZ Vendetta 2
GPU cooling
Accerlero S1
OS
Vista 64bit
Monitor
Samsung T200
darius_m5 is offline   Reply With Quote
Old 10-03-09   #3 (permalink)
PC Gamer
 
nachosanchezz's Avatar
 
intel nvidia

Join Date: Jan 2009
Location: Christchurch, New Zealand
Posts: 466

Rep: 19 nachosanchezz Unknown
Unique Rep: 18
Trader Rating: 0
Default

Quote:
Originally Posted by darius_m5 View Post
Here's something I just wrote.

You choose the URL's you want in the array, then it will randomly load them.

The timeout is set to 600000 Miilliseconds (10 minutes).

Code:
// ==UserScript==
// @name           Random Url's
// @namespace      http://userscripts.org
// @include        *
// ==/UserScript==

//declare variables
var rand1,rand2;

//URL array, add as many as you want.
var urls=['http://google.com','http://youtube.com','http://overclock.net']

//set rand2 to a random number between 0 and 600000 milliseconds
rand2=Math.floor(Math.random()*600000);

//Tell browser to load the load_url function after the random time (rand2)
window.setTimeout(load_url,rand2);

//And here's the function that changes the page
function load_url(){
        //get a random number to choose a random url
	rand1=Math.floor(Math.random()*urls.length);
        //make the page go to the random url
	location.href=urls[rand1];
	}
Thank you very much! Much appreciated.

System: My PC
CPU
E6420 - lapped
Motherboard
Asus P5Q
Memory
2x1GB Kingston DDR2-800
Graphics Card
XFX 8600GT XXX (4850 soon)
Hard Drive
WD 250GB
Sound Card
Onboard
Power Supply
CM Silent Pro M600 600W
Case
XG Sidewinder II
CPU cooling
Lapped TR Ultima-90 w/ Scythe Kama PWM 120mm
OS
Windows 7 Pro x64 RTM
Monitor
Viewsonic 19" @ 1280x1024
nachosanchezz is offline   Reply With Quote
Old 10-03-09   #4 (permalink)
PC Gamer
 
nachosanchezz's Avatar
 
intel nvidia

Join Date: Jan 2009
Location: Christchurch, New Zealand
Posts: 466

Rep: 19 nachosanchezz Unknown
Unique Rep: 18
Trader Rating: 0
Default

I just realised I have no idea of how to actually install/activate a user script so Greasemonkey will implement it.... Anyone care to explain please?

System: My PC
CPU
E6420 - lapped
Motherboard
Asus P5Q
Memory
2x1GB Kingston DDR2-800
Graphics Card
XFX 8600GT XXX (4850 soon)
Hard Drive
WD 250GB
Sound Card
Onboard
Power Supply
CM Silent Pro M600 600W
Case
XG Sidewinder II
CPU cooling
Lapped TR Ultima-90 w/ Scythe Kama PWM 120mm
OS
Windows 7 Pro x64 RTM
Monitor
Viewsonic 19" @ 1280x1024
nachosanchezz is offline   Reply With Quote
Old 10-04-09   #5 (permalink)
Overclocker in Training
 
darius_m5's Avatar
 
intel ati

Join Date: Sep 2008
Location: Toronto, Ontario
Posts: 104

Rep: 19 darius_m5 Unknown
Unique Rep: 16
Trader Rating: 0
Default

Right click on the little greasemonkey icon.
Click New User Script.

Choose a name.
Put down * for includes.
Then Click OK.

When the text editor opens, just copy and paste the script you want.

When you're browsing the internet and you open a *.user.js file, Greasemonkey will automatically install the script for you.

More Info
__________________
System: CM HAF 932
CPU
E8400
Motherboard
P5Q-Pro
Memory
OCZ 2x2GB PC2-8500
Graphics Card
Sapphire 4850
Hard Drive
2xWD 320GB Caviar
Power Supply
Enermax Infiniti 720W
Case
CM HAF 932
CPU cooling
OCZ Vendetta 2
GPU cooling
Accerlero S1
OS
Vista 64bit
Monitor
Samsung T200
darius_m5 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 09:35 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.12200 seconds with 8 queries