views:

37

answers:

1

I'm working on a script to click a button. The button is part of a script that is embedded on a website. The embedded script is here: http://pastebin.com/jsBiYZxi I'm fairly new to Greasemonkey and javascripting in general and I'm hitting a road block trying to accomplish this. Can anyone give me some pointers or suggestions?

A: 

Looking at that code, the page uses jQuery and the button has class play and is inside a form that is inside a div with id button.

So, unsafeWindow.$("#button form input.play").click(); in your Greasemonkey script will click it.

That answers the question as stated.
You didn't say that you wanted to also defeat the button's associated timer. But, if you do, that is quite a bit more involved since the timer is defined inside an anonymous function.

There are also ethical concerns with defeating the timer. The site owner may be using that timer to stop abuse/drain by users and bots (he's providing the "service" for free and doesn't even seem to have advertising). So helping to defeat or overload the site wouldn't be right.

Brock Adams
You're absolutely right there is an ethical dilemma. We are playing a game and the purpose of the game is really to click the button. So when I'm not at my computer I want to make sure that my button is being pressed. It's already pretty clear that others have developed scripts to click the button and some people have even admitted it but no one shares that kind of information so I decided to try and craft my own.
Gordon
@Gordon: If you just want to have a bot clicking while you're not at the computer and you're not trying to defeat the timer, then wrapping that click-code in a `setInterval()` should work. Just make the interval longer than the max timer val (maybe 100 seconds).
Brock Adams