共享新浪微博好友组给你的其他关注者的代码

// jQuerify via fireQuery plugin — firebug plugin — firstly
// 你需要使用firebug,并安装fireQuery插件,jquerify之后,再运行此段代码,
// this piece of code will help you to share all of your friends in specify group with your followers
// 这段代码将帮助你共享你的特定好友组的好友给你的关注者们

(function() {

if (typeof jQuery == ‘undefined’ || !jQuery.get) {
alert(“Sorry, but your should jQuerify your weibo.com via FireQuery plugin under Firebug first! nn 对不起,你应当使用Firebug 下的 FireQuery插件先把页面加载上 jQuery 哦!”);
return;
}

;(function(){
// this is your friend group url, you must click your friend group, and copy the url to this place
// 这是你的好友组的URL,你必须先点击你的好友分组,然后把地址栏的URL拷贝过来
// 默认是小方的组
var groupBaseUrl = ‘http://weibo.com/1200172590/follow?&gid=201008300003939366’ + ‘&tag=&page=’;

// how many pages of your friend group are? you can get from the pagination area at the bottom of the page
// 你的好友组共有好友几页呢?你可以从页面下面的分布跳转区看到
var pages = 6;// customized

var tmpCounter = pages;

var dataToPost = [];

// jQuery selector to find the name area of every list, may be change in the future
// jQuery 选择器,用来查找各个好友的名字,将来可能会有改动
var listDataSelector = ‘li.MIB_linedot_l.conspace span.name’;

// how many people in a post
// 一个帖子要发几个人
var peoplePerPost = 20; // people number in a post

// people spliter
// 名字分隔符
var peopleSpliter = ‘ //// ‘; // people number in a post

// your home page url
// 你的主页的URL
// 默认是小方的主页
var postReferer = ‘http://weibo.com/lanshunfang’;

// extra description text for group
var groupDesc = ‘守望肢体’;

// main process
// 主体过程
for (var i = 1; i <= pages; i++) {.get(groupBaseUrl + i, function(response) {

(response).find(listDataSelector).each(function(){
var
this = (this);
var _note =
this.find(‘span > a’).text();
// remove empty note
if (_note == ‘设置备注’) {
_note = ”;
}
var _str = ‘@’ + this.children(‘a’).text() + ‘ 这是’ + groupDesc + ‘ ‘ + _note;
dataToPost.push(_str);
});

tmpCounter–;

});
}

var checker = setInterval(function(){
if (tmpCounter == 0) {
post(dataToPost);
clearInterval(checker);
}
}, 1000);

var post = function(dataToPost) {
var intval = setInterval(function(){
if (!dataToPost.length) {
// if not any data to post, clear interval, return
clearInterval(intval);
return;
}
// string to post
var stringToPost = ”;
var _oriString = ”;
var _tmpElement = {};
for (var j = 0; j139) {
window.console && console.log(
‘too much people in a post, auto cut at number:’ + j + ‘, at name ‘ + _tmpElement
);
// store back
dataToPost.push(_tmpElement);
stringToPost = _oriString;
break;
}
}
var _now =.now();
window.console && console.log(stringToPost);
window.console && console.log(dataToPost);
if (stringToPost == ”) {
return;
}
$.ajax({
url: ‘http://weibo.com/aj/mblog/add?__rnd=’ + _now,
type: ‘post’,
data: {
_t: ‘0’,
location: ‘home’,
module: ‘stissue’,
pic_id: ”,
text: stringToPost
},
beforeSend: function(xhr) {
xhr.setRequestHeader(“Accept”, “text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8”);
xhr.setRequestHeader(“Accept-Language”, “zh-cn,zh;q=0.5”);
xhr.setRequestHeader(“Accept-Encoding”, “gzip, deflate”);
xhr.setRequestHeader(“Accept-Charset”, “GB2312,utf-8;q=0.7,*;q=0.7”);
xhr.setRequestHeader(“Keep-Alive”, “115”);
xhr.setRequestHeader(“Connection”, “keep-alive”);
xhr.setRequestHeader(“Content-Type”, “application/x-www-form-urlencoded; charset=UTF-8”);
xhr.setRequestHeader(“X-Requested-With”, “XMLHttpRequest”);
xhr.setRequestHeader(“Referer”, postReferer); // TODO
},
success: function(response) {
if (response.code != 100000) {
// failed
dataToPost.push(_tmpElement);
window.console && console.log(‘posting failed, at name’ + stringToPost + ‘, it will be retried later’);
}
}
});
}, 5000);
}

})(jQuery);

}());