Skip to content

Instantly share code, notes, and snippets.

@yuanchuan
Forked from anonymous/gist:997052
Created May 30, 2011 00:47
Show Gist options
  • Save yuanchuan/998296 to your computer and use it in GitHub Desktop.
Save yuanchuan/998296 to your computer and use it in GitHub Desktop.
在搜狐空间里自动获取最新动态
// pull.every(10);
// pull.stop();
var pull = (function(container){
var target, event, timer;
if (container) {
target = container.getElementsByTagName('a')[0];
}
return {
every: function(sec) {
timer && this.stop();
timer = setInterval(function(){
event = document.createEvent("MouseEvents");
event.initMouseEvent("click", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
target && target.dispatchEvent(event);
}, (~~sec * 1000) || 2000);
},
stop: function(){
timer && clearInterval(timer);
}
}
})(document.getElementById("feedTabs"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment