// 在 B 站打开任意 page(已登录),在控制台粘贴运行
const uids = [1042653845,
1055149070,
1075400468,
1148923121,
1152997930,
1188004959,
1208114979,
1227735707,
1252039983,
1257852431,
1302669433,
1356882480,
1430439192,
1627242161,
1642531925,
1655279349,
1720634591,
1743345026,
1798118517,
1806922031,
1817661914,
1826766269,
1859459400,
1919627194,
1926952280,
1956866386,
1957313739,
1987938455,
1992873935,
2024349971,
2067273601,
2072500476,
2101682498,
2103756604,
2115931056,
2118239887,
2126699792];

// 从 document.cookie 里尝试提取 csrf token bili_jct
function getCookie(name) {
  const m = document.cookie.match(new RegExp('(^|; )' + name + '=([^;]*)'));
  return m ? decodeURIComponent(m[2]) : '';
}
const bili_jct = getCookie('bili_jct');
if(!bili_jct) {
  console.error('无法找到 bili_jct,请确保已登录并且 cookie 可用');
}

async function blockUid(uid) {
  const url = 'https://api.bilibili.com/x/relation/modify?statistics=%7B%22appId%22:100,%22platform%22:5%7D';
  const body = new URLSearchParams({
    fid: String(uid),
    act: '5',
    re_src: '11',
    gaia_source: 'web_main',
    extend_content: JSON.stringify({ entity: 'user', entity_id: String(uid) }),
    csrf: bili_jct
  });
  const resp = await fetch(url, {
    method: 'POST',
    headers: {
      'content-type': 'application/x-www-form-urlencoded',
      'origin': 'https://space.bilibili.com',
      'referer': `https://space.bilibili.com/${uid}/dynamic`,
    },
    body: body.toString(),
    credentials: 'include'
  });
  const j = await resp.json().catch(()=>null);
  return { uid, status: resp.status, body: j ?? null };
}

(async () => {
  for (const uid of uids) {
    // 可选延时: await new Promise(r=>setTimeout(r, 300));
    const r = await blockUid(uid);
    console.log(r);
  }
  console.log('finished');
})();
 
 
Back to Top