Skip to content

Instantly share code, notes, and snippets.

@houkanshan
Created April 13, 2012 11:50
Show Gist options
  • Save houkanshan/2376278 to your computer and use it in GitHub Desktop.
Save houkanshan/2376278 to your computer and use it in GitHub Desktop.
发一个蛋疼的状态(你说我改个小东西github也要发个新鲜事,好蛋疼啊??)
//用这个在人人发状态, 可以做到........ 让你的最近一条状态为'什么也没做...'
//支持renren新旧版本.
//呵呵
(function(document){
var h_iframes = document.getElementsByTagName('iframe');
var proxy;
var id;
var patten = /status/g;
var text = document.getElementsByClassName('status-content')[0].value;
for(var i = 0; i < h_iframes.length; ++i){
var src = h_iframes[i].getAttribute('src');
if(patten.test(src)){
proxy = h_iframes[i];
}
}
function sendStatu(msg,callback){
var xhr = proxy.contentWindow.getTransport();
var sendMsg = encodeURIComponent(msg);
xhr.onreadystatechange = function(event){
if(xhr.readyState == 4){
if((xhr.status >=200 && xhr.status < 300) || xhr.status == 304){
var response = XN.JSON.parse(xhr.responseText);
id = response.updateStatusId;
callback && callback();
}else{
console.log(xhr.status, xhr.statusText);
}
}
};
xhr.open('post', 'http://status.renren.com/doing/update.do?');
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send('c='+sendMsg+'&raw='+sendMsg+'&&publisher_form_ticket='+XN.get_check+'&requestToken='+XN.get_check+'&_rtk='+XN.get_check_x);
}
function deleteStatu(callback){
var xhr = proxy.contentWindow.getTransport();
xhr.open('post', 'http://status.renren.com/doing/deleteDoing.do?');
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function(event){
if(xhr.readyState == 4){
if((xhr.status >=200 && xhr.status < 300) || xhr.status == 304){
callback && callback();
}else{
console.log(xhr.status, xhr.statusText);
}
}
};
xhr.send('id='+id+'&requestToken='+XN.get_check+'&_rtk='+XN.get_check_x);
}
sendStatu(text,setTimeout(function(){
sendStatu(';)', function(){deleteStatu(function(){window.location.reload()})});
},2*1000));
}(document));
@bcho
Copy link

bcho commented Sep 1, 2012

命名有长度限制么?为什么都是 Statu ……

@houkanshan
Copy link
Author

刚学js的时候写的。。。代码风格好烂。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment