jquery – Use Greasemonkey to click button that was created by JavaScript – Education Career Blog

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?


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.

Leave a Comment