By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,454 Members | 3,208 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,454 IT Pros & Developers. It's quick & easy.

Greasemonkey and Some Automation

P: 1
Greetings. I have recently discovered the Grease Monkey add-in for FireFox. It has a lot of potential, and I am really enjoying using it to simplify and automate some repetitive tasks I perform on a regular (several times a day) basis.

Here is what I cannot figure out:
One site I visit (PHP) generates a list of links based on certain conditions (time of day, luck of the draw, who knows?). I want to click a SPECIFIC link if it exists. If not, I'd like to reload the page and try again.

The link I want is in the format [normal url].html / something.php?a=var1&b=var2

The var1 and var2 will change based on the conditions that I have yet to determine (see above). If that link shows up on the page somewhere, then I want to click it.

I tried to use an array and just pull the link if it is there, but the number of links on the page is not constant, and the position in the array for the specified link was not constant.

I worked a small amount with some Regular Expressions until my script stopped working altogether (leading me to believe I should have paid attention in my C++ classes a little more).

If you have any ideas, I'd love to give them a try. It just seems like I'm missing something really quite simple and would like to be able to automate this task (to keep from having to click refresh several times to find the link).

I want this to work in FireFox with GreaseMonkey (which just uses standard JavaScript).

Thank you for your help.
Jan 18 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

Use document.getElementsByTagName("a") to get the links on the page then loop over them to check that one of them is the correct link.
Jan 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.