开发者

click a button automatically using greasemonkey

开发者 https://www.devze.com 2023-01-03 18:45 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号