

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")