Last active
March 20, 2016 05:12
-
-
Save Senorsen/349afdbb1fcf9bee188d to your computer and use it in GitHub Desktop.
weibo unfollower
This file contains 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
// 先加载 jQuery | |
loadScript('http://code.jquery.com/jquery-2.2.2.js', function () { | |
var users = []; | |
$('.member_li').each(function () { | |
var userArr = $(this).attr('action-data').split('&'); | |
for (var i in userArr) { | |
userArr[i] = userArr[i].split('='); | |
} | |
var userObj = {}; | |
userArr.forEach(function (v) { | |
userObj[v[0]] = decodeURI(v[1]); | |
}); | |
users.push(userObj); | |
}); | |
users.forEach(function (user) { | |
$.post('http://weibo.com/aj/f/unfollow?ajwvr=6&__rnd=' + $.now(), { | |
refer_sort: 'relationManage', | |
location: 'page_100505_myfollow', | |
refer_flag: 'unfollow', | |
uid: user.uid, | |
gid: user.gid, | |
gname: user.gname, | |
remark: user.remark, | |
screen_name: user.screen_name, | |
sex: user.sex, | |
_t: 0 | |
}, function (data) { | |
if (data.code === "100000") { | |
console.log('成功取关 ' + user.remark + ' ' + user.screen_name); | |
} else { | |
console.error('失败 ' + user.uid, data, user); | |
} | |
}, 'json'); | |
}); | |
}); | |
// # loadScript from http://www.sitepoint.com/dynamically-load-jquery-library-javascript/ | |
function loadScript(url, callback) { | |
var script = document.createElement("script") | |
script.type = "text/javascript"; | |
if (script.readyState) { //IE | |
script.onreadystatechange = function () { | |
if (script.readyState == "loaded" || script.readyState == "complete") { | |
script.onreadystatechange = null; | |
callback(); | |
} | |
}; | |
} else { //Others | |
script.onload = function () { | |
callback(); | |
}; | |
} | |
script.src = url; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment