使用Greasemonkey每5秒执行一次Javascript吗? [英] Using Greasemonkey to execute Javascript every 5 seconds?

查看:104
本文介绍了使用Greasemonkey每5秒执行一次Javascript吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Greasemonkey和javascript的新手,但已找到以下脚本,我想每5秒执行一次.

I am new to Greasemonkey and javascript but have found the script below, I want to execute it every 5 seconds.

javascript:$('.comments-stream .more:not(.dnone)').parent().find('.fa-minus').parent() .click();

有什么办法吗?

推荐答案

使用setInterval.请注意我如何从单击功能中删除括号.

Use setInterval. Notice how i removed the parentheses from the click function.

javascript:setInterval($('.comments-stream .more:not(.dnone)').parent().find('.fa-minus').parent() .click, 5000);

如果您想做更多的事情,只需单击一下即可.

If you want to do more then just the click.

javascript:setInterval(function(){
    $('.comments-stream .more:not(.dnone)').parent().find('.fa-minus').parent() .click();
, 5000);

这篇关于使用Greasemonkey每5秒执行一次Javascript吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆