简体   繁体   English

使用greasemonkey自动单击一个按钮

[英]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. 我需要一个greasemonkey脚本,甚至在页面完全加载之前必须自动点击按钮并转到下一页。

Thanks. 谢谢。

I need a greasemonkey script which even before the page completely loads must automatically click on the button and move to next page. 我需要一个greasemonkey脚本,甚至在页面完全加载之前必须自动点击按钮并转到下一页。

With Greasemonkey, you currently can only run a user script on DOM ready which is just before the page load is complete. 使用Greasemonkey,您当前只能在DOM就绪之前运行用户脚本,就在页面加载完成之前。

With user scripts used on Google Chrome they can run sooner, and eventually you will be able to run userscripts before DOM ready. 使用Google Chrome上的用户脚本,他们可以更快地运行,最终您可以在DOM准备好之前运行用户脚本。

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 应该做的伎俩

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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