Created
April 13, 2012 11:50
-
-
Save houkanshan/2376278 to your computer and use it in GitHub Desktop.
发一个蛋疼的状态(你说我改个小东西github也要发个新鲜事,好蛋疼啊??)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//用这个在人人发状态, 可以做到........ 让你的最近一条状态为'什么也没做...' | |
//支持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)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
命名有长度限制么?为什么都是 Statu ……