Diskuse » Greasy Fork Feedback
Convert JS code to script
i got some examples
/////Use setInterval to automatically call the specified function periodically:
var interval = setInterval(function() {
// do ajax request
...............
}, 60 * 1000);
if (some_condition) {
clearInterval(interval); // stop the timer
}
/////Use setTimeout to schedule one run of the function based on condition:////////////////////
var timeout;
(function doAjax() {
// do ajax request
...............
if (some_condition) {
timeout = setTimeout(doAjax, 60 * 1000); // schedule the next run
}
})();
if (another_condition) {
clearTimeout(timeout); // cancel the schedule
}
/////////////////////or the easy way////////
(function(){
// what should be done every 5 seconds
setTimeout(arguments.callee, 5000);
})();
kinda like that
Convert JS code to script
I have a piece of code and I want it to be executed every 5 seconds on facebook.
I have created a new user script and pasted the javascript code but it do not execute