views:

148

answers:

1

Hi all,

There is a button in the web page as

<input class="button" type="submit" value="new">

I need a greasemonkey script which even before the page completely loads must automatically click on the button and move to next page.

Thanks.

+1  A: 

I need a greasemonkey script which even before the page completely loads must automatically click on the button and move to next page.

With Greasemonkey, you currently can only run a user script on DOM ready which is just before the page load is complete.

With user scripts used on Google Chrome they can run sooner, and eventually you will be able to run userscripts before DOM ready.

As for the code to select and click that button:

document.evaluate("//input[@value='new' and @type='submit' and contains(@class, 'button')]", document, null, 9, null).singleNodeValue.click();

should do the trick

Erik Vold
Hey there, I need the greasemonkey script, i would be running it on firefox. And it doesn't matter if the button is clicked just before the page load is complete. Thanks.
muqtar
Well then just put the code above into a .user.js file and add a [metadata block](http://wiki.greasespot.net/Metadata_Block), then drag and drop that in to firefox, install and that should work.
Erik Vold
i've done that,but the code isn't working.. can u help me with the greasemonkey script code.
muqtar
Any help from anybody appreciated,thanks
muqtar
can you upload the code to gist.github.com ? or someplace else?
Erik Vold
hey,i've posted the html code of webpage at http://gist.github.com/453236 ,download the code and extract the html file and run it view its source and find the button mentioned above.. i need this button to be clicked as soon as the page loads using greasemonkey.. Thanks
muqtar