为了偷懒给这个代码逆向了一下,使用起来更方便,虽然不触犯x的法规,但粉丝多的谨慎使用。
(function() {
console.log("🚀 开始过滤单向关注用户(隐藏互关,只显示你关注但他们没关注你的人)...");
// 可自定义选项
const hideMutuals = true; // true: 隐藏互关;false: 只淡化互关,不隐藏
const highlightColor = 'rgba(255, 182, 193, 0.2)'; // 浅粉色背景(单向突出)
const borderStyle = '2px solid
#FF69B4'; // 粉色边框
const fadeOpacity = 0.2; // 如果不隐藏,用这个降低互关透明度
const followsYouTexts = ['Follows you', '关注了你', 'フォロー中', 'フォローしています', 'Te sigue']; // 支持多语言
let singleCount = 0;
let mutualCount = 0;
const filterSingleDirection = (mutations = null) => {
try {
let userCells = [];
if (mutations) {
console.log("🔍 Observer 检测到变化,正在处理新增节点...");
mutations.forEach(mutation => {
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
mutation.addedNodes.forEach(node => {
if (node.nodeType === 1 && node.querySelectorAll) { // 只处理元素节点
userCells.push(...node.querySelectorAll('[data-testid="UserCell"]'));
// 递归查找子节点中的UserCell
node.querySelectorAll('[data-testid="UserCell"]').forEach(cell => userCells.push(cell));
}
});
}
});
} else {
console.log("🔍 初始或轮询检查所有未处理卡片...");
userCells = Array.from(document.querySelectorAll('[data-testid="UserCell"]')).filter(cell => !cell.classList.contains('is-processed'));
}
if (userCells.length === 0) {
console.log("⚠️ 没有找到新用户卡片。确保在Following页面,并滚动加载更多。");
return;
}
console.log(`📥 处理 ${userCells.length} 个新用户卡片...`);
userCells.forEach(cell => {
const followsYouLabel = Array.from(cell.querySelectorAll('span')).find(
el => followsYouTexts.some(text => el.textContent.trim().includes(text))
);
if (followsYouLabel) {
mutualCount ;
if (hideMutuals) {
cell.style.display = 'none';
} else {
cell.style.opacity = fadeOpacity;
}
console.log(`❌ 隐藏/淡化互关: ${getUsername(cell)}`);
} else {
singleCount ;
cell.style.backgroundColor = highlightColor;
cell.style.border = borderStyle;
console.log(`✅ 显示单向关注: ${getUsername(cell)}`);
}
cell.classList.add('is-processed');
});
console.log(`📊 当前统计: 单向 ${singleCount} 个,互关 ${mutualCount} 个`);
} catch (error) {
console.error("❌ 错误: ", error);
}
};
// 提取用户名函数(更精确)
const getUsername = (cell) => {
const usernameElem = cell.querySelector('a[href^="/"] div[dir="ltr"] > span > span'); // X的标准用户名span
return usernameElem ? usernameElem.textContent.trim() : '未知用户';
};
// 初始运行
filterSingleDirection();
// MutationObserver
const target = document.querySelector('[data-testid="primaryColumn"]') || document.body;
if (!target) {
console.warn("⚠️ 未找到primaryColumn,确保在X页面。");
} else {
const observer = new MutationObserver(filterSingleDirection);
observer.observe(target, { childList: true, subtree: true, attributes: false });
console.log("👀 Observer 已启动,监控页面变化。");
}
// 后备轮询(每2秒检查一次未处理卡片)
const pollInterval = setInterval(() => filterSingleDirection(), 2000);
console.log("🔄 后备轮询已启动,每2秒检查一次。");
// 清理(可选,页面卸载时)
window.addEventListener('beforeunload', () => {
observer.disconnect();
clearInterval(pollInterval);
});
console.log("💡 过滤已开启。请慢慢向下滚动,观察控制台日志。新加载的互关用户应被隐藏。如果仍无效,复制日志反馈。");
})();
如何快速找到互粉取关的用户~浏览器操作 无自动化 安全可视
看来大家对这种行为都还蛮不齿的
———
自己转发下 看起来大家还蛮需要的