Created
November 8, 2013 10:41
-
-
Save yanhaijing/7369304 to your computer and use it in GitHub Desktop.
自动follow 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
(function ($) { | |
var | |
followers = ["zedshaw"]; | |
followeds = []; | |
function follow(id, callback) { | |
$.post('https://github.com/users/follow', {target: id}, function(data, textStatus, xhr) { | |
/*optional stuff to do after success */ | |
callback(id, data); | |
//console.log("成功follow ", id, "此人共有", data.count, "位粉丝"); | |
}, "json"); | |
} | |
function unFollow(id, callback) { | |
$.post('https://github.com/users/unfollow', {target: id}, function(data, textStatus, xhr) { | |
/*optional stuff to do after success */ | |
callback(id, data); | |
}, "json"); | |
} | |
function getFollowers(id, callback) { | |
$.get("https://github.com/" + id + "/followers", {}, function (data) { | |
var a = $(data).find(".minibutton:not(.btn-unfollow)"); | |
a.each(function () { | |
var | |
id = $(this).attr("data-user"); | |
if (typeof followeds[id] === "undefined") { | |
followers.push(id); | |
} | |
}); | |
console.log(followers); | |
callback(); | |
}, "html"); | |
} | |
function getFollower() { | |
var | |
id = followers.pop(); | |
if (typeof id !== "undefined") { | |
followeds[id] = id; | |
return id; | |
} | |
return false; | |
} | |
// follow(getFollower(), function (id, data) { | |
// unFollow(id, function (id, data) { | |
// getFollowers(id); | |
// follow(getFollower()); | |
// }); | |
// }); | |
function callback(id, data) { | |
getFollowers(id, function () { | |
window.setTimeout(function () { | |
var | |
id = getFollower(); | |
if (id) { | |
follow(id, callback); | |
} | |
}, 1000); | |
}); | |
} | |
follow(getFollower(), callback); | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment