简体   繁体   中英

click a button automatically using greasemonkey

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM