quicknote/weibo/follow.js

38 lines
1013 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
const batchFollow = async (list = [], index = 0) => {
const followUserId = list[index]
await fetch(`/ajax/friendships/create`, {
method: 'POST',
headers: {
"content-type": 'application/json;charset=UTF-8',
"accept": "application/json, text/plain, */*",
"x-xsrf-token": token
},
body: JSON.stringify({
friend_uid: followUserId,
lpage: "profile",
page: "profile"
}
)
}).then(res => res.json()).then((res) => {
console.log(`[${++index}/${list.length}],${res.name},关注成功`)
})
if (list.length > index) {
await sleep(4000 +Math.round(Math.random() * 100))
await batchFollow(list, index)
}
return list
}
const start = async (t) => {
token = t
list = [1634187662,6234298456]
console.log(`获取列表成功,共${list.length}`);
batchFollow(list)
}
start("TOd_QJSv0vqz9CKjPVSrirNX") //例如start("ApMq0KHPGo3SBclIGe6dMpn7")