|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Web Coding | |
Help with JavaScript for Greasemonkey
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | ||||||||||||
|
PC Gamer
Join Date: Jan 2009
Location: Christchurch, New Zealand
Posts: 466
Rep: 19
![]() Unique Rep: 18
Trader Rating: 0
|
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.
__________________
Last edited by nachosanchezz : 10-03-09 at 09:06 AM |
||||||||||||
|
|
|
|
|
#2 (permalink) | ||||||||||||
|
Overclocker in Training
|
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];
}
|
||||||||||||
|
|
|
|
|
#3 (permalink) | |||||||||||||
|
PC Gamer
Join Date: Jan 2009
Location: Christchurch, New Zealand
Posts: 466
Rep: 19
![]() Unique Rep: 18
Trader Rating: 0
|
Quote:
__________________
|
|||||||||||||
|
|
|
|
|
#4 (permalink) | ||||||||||||
|
PC Gamer
Join Date: Jan 2009
Location: Christchurch, New Zealand
Posts: 466
Rep: 19
![]() Unique Rep: 18
Trader Rating: 0
|
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?
__________________
|
||||||||||||
|
|
|
|
|
#5 (permalink) | ||||||||||||
|
Overclocker in Training
|
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
|
||||||||||||
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|