6-21,实在写不下去毕业论文。
B站关注已经一千三百多了...最近清了YouTube的subscribe list,但阿b要检查的up数量是油管的几十倍,只好让chatgpt写个脚本:
// 适配新版B站“我的关注”页面的一键取关脚本
(async () => {
const sleep = t => new Promise(r => setTimeout(r, t));
let removed = 0;
// 获取所有“已关注”按钮(新版 DOM)
const getFollowedDivs = () =>
[...document.querySelectorAll("div.follow-btn__trigger")].filter(
el => el.textContent.trim() === "已关注"
);
while (true) {
const followedDivs = getFollowedDivs();
if (followedDivs.length === 0) {
console.log("[完成] 没有可取消关注的了。共取消:" + removed + " 人");
break;
}
for (let el of followedDivs) {
el.click();
await sleep(300); // 等弹出层加载
const confirmBtn = document.querySelector(".pop-confirm-btn");
if (confirmBtn) {
confirmBtn.click();
removed++;
console.log(`[取关] 第 ${removed} 人`);
await sleep(800); // 避免过快被风控
}
}
// 尝试翻页
const nextPageBtn = document.querySelector(".vui_pagenation--btn-side:not([disabled]):last-child");
if (nextPageBtn) {
nextPageBtn.click();
console.log("[翻页] 跳到下一页");
await sleep(2500); // 等页面加载
} else {
console.log("[结束] 没有下一页了");
break;
}
}
})();
一键清理,互粉的不取关,每个等0.8s,翻页等2.5s,居然一共需要17+分钟。