问题
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