Using Greasemonkey to execute Javascript every 5 seconds? [duplicate]

拈花ヽ惹草 提交于 2019-12-13 05:08:59

问题


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();

Is there any way of doing this?


回答1:


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);


来源:https://stackoverflow.com/questions/28657604/using-greasemonkey-to-execute-javascript-every-5-seconds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!