Repository navigation
Expand file tree
/
Copy pathweibo.js
More file actions
77 lines (61 loc) · 2.81 KB
/
Copy pathweibo.js
File metadata and controls
77 lines (61 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// == 拟人化批量设置微博为“仅自己可见”,好友圈可见也处理 ==
// 参数
var intervalTime = 3000; // 每轮检查间隔
var scrollStep = 200; // 每次平滑滚动距离(px)
var menuDelay = 600; // 菜单渲染延迟
var confirmDelay = 300; // 确认按钮延迟
// 循环处理微博
function processWeiboBatch() {
// 找所有“更多操作”按钮
var menuButtons = Array.from(document.querySelectorAll('i.woo-font.woo-font--angleDown[title="更多"]'))
.filter(btn => {
if (btn.dataset.clicked) return false; // 已处理过的跳过
let card = btn.closest('div.woo-box-flex');
if (!card) return true;
// 仅跳过已经是“仅自己可见”的微博
let visibilityTag = card.querySelector('span.title_title_1DVuO');
if (visibilityTag && visibilityTag.innerText.includes('仅自己可见')) return false;
return true; // 其他微博处理,包括好友圈可见
});
if (menuButtons.length === 0) {
// 没有可处理按钮 → 平滑往下滚
window.scrollBy({ top: scrollStep, behavior: 'smooth' });
console.log('未找到可处理微博,滚动加载更多…');
return;
}
// 逐个处理按钮
menuButtons.forEach((btn, index) => {
setTimeout(() => {
try {
// 点击“更多操作”
btn.click();
btn.dataset.clicked = "true"; // 标记已点击
setTimeout(() => {
// 找菜单里的“转换为自己可见”
var personalBtn = Array.from(document.querySelectorAll('div.woo-box-flex.woo-box-alignCenter.woo-pop-item-main'))
.find(d => d.innerText.includes('转换为自己可见'));
if (personalBtn) personalBtn.click();
// 点击确认按钮
setTimeout(() => {
var okBtn = Array.from(document.querySelectorAll('div, a'))
.find(el => el.innerText.includes('确定'));
if (okBtn) okBtn.click();
// 点击空白区域关闭菜单
document.body.click();
console.log('✅ 已转换为仅自己可见');
}, confirmDelay);
}, menuDelay);
} catch (e) {
console.log('处理按钮出错:', e);
}
}, index * 600 + Math.random() * 400); // 随机延迟,模拟人工
});
// 处理完一批后,继续平滑滚动
setTimeout(() => {
window.scrollBy({ top: scrollStep, behavior: 'smooth' });
}, intervalTime / 2);
console.log('本轮处理完成,尝试点击', menuButtons.length, '个“更多操作”按钮');
}
// 启动循环
var intervalId = setInterval(processWeiboBatch, intervalTime);
console.log('拟人化批量脚本已启动,每', intervalTime, '毫秒检查微博。停止请执行:clearInterval(intervalId);');