Skip to content

Instantly share code, notes, and snippets.

@kainy
Created April 4, 2015 04:41
Show Gist options
  • Save kainy/204cb479f7d4c3703392 to your computer and use it in GitHub Desktop.
Save kainy/204cb479f7d4c3703392 to your computer and use it in GitHub Desktop.
内网KM自动关注和自动访问
(function(){
var i= document.createElement('iframe');
i.src='http://km.oa.com/users/follow_user/kainyguo';
i.style.display= 'none'
i.onload= function(){
i.parentNode.removeChild(i);
}
document.body.appendChild(i);
})();
(function(){
var src= [
//就地取材,拿自动补全用户名的脚本获取KM用户ID信息
'http://top.oa.com/js/users.js?v=20130621'
];
var count= 0;
for(var i= src.length; i> 0; i--){
var c = document.createElement('script');
c.type = 'text/javascript';
c.async = false;
c.src = src[i-1];
c.onload= visit;
var h = document.getElementsByTagName('script')[0];
h.parentNode.insertBefore(c, h);
}
function visit(){
//随机产生被访问用户ID
var i= Math.floor(Math.random()* _arrusers.length);
//构造url
var url= 'http://km.oa.com/user/'+ _arrusers[i][0];
//发起虚假访问请求
$.ajax({
method: 'get',
url: url,
success: function(){
console.log(url, i, count++);
//间隔2s循环执行
setTimeout(visit, 2* 1000);
}
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment