- 精华
- 阅读权限
- 130
- 贡献
- 人
- 好友
- 相册
- 分享
- 听众
- 收听
- 注册时间
- 2008-12-8
- 在线时间
- 小时
- 最后登录
- 1970-1-1
|
近期有几个绝户ID不停的在发垃圾推广帖。
由于论坛没有管理,只能靠各位自己想办法。
推挤给大家一个方法,先在浏览器安装油猴插件,然后把下面的脚本写入到插件里,输入绝户ID之后,就能把那几个绝户ID的帖子都屏蔽掉。
屏蔽绝户ID之后就干净很多了。
// ==UserScript==
// @name 藏宝湾论坛 - 屏蔽指定用户帖子(修复版)
// @namespace http://tampermonkey.net/
// @version 2.1
// @description 针对藏宝湾(iopq.net)优化,隐藏黑名单用户发布的所有主题,支持多种分隔符批量添加
// @Match https://www.iopq.net/forum.php?mod=forumdisplay*
// @match https://www.iopq.net/forumdisplay.php*
// @match https://www.iopq.net/*
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @grant GM_notification
// ==/UserScript==
(function() {
'use strict';
// ---------- 数据管理 ----------
function getBlockedUsers() {
let data = GM_getValue('blockedUsers', '[]');
try { return JSON.parse(data); } catch(e) { return []; }
}
function setBlockedUsers(users) {
GM_setValue('blockedUsers', JSON.stringify(users));
}
// ---------- 从帖子行(tbody)提取作者名 ----------
function getAuthorFromRow(tbody) {
let authorLink = tbody.querySelector('td.by cite a');
if (authorLink) {
return authorLink.textContent.trim();
}
let link = tbody.querySelector('a[href*="space-uid"]');
if (link) {
return link.textContent.trim();
}
return null;
}
// ---------- 执行屏蔽 ----------
function hideBlockedUsers() {
let blocked = getBlockedUsers();
if (blocked.length === 0) return;
let rows = document.querySelectorAll('#threadlisttableid > tbody[id^="normalthread_"]');
rows.forEach(tbody => {
if (tbody.style.display === 'none') return;
let author = getAuthorFromRow(tbody);
if (author && blocked.includes(author)) {
tbody.style.display = 'none';
}
});
}
// ---------- 管理菜单 ----------
function addMenu() {
GM_registerMenuCommand('📋 屏蔽用户管理', function() {
let current = getBlockedUsers().join('\n');
let input = prompt(
'当前屏蔽列表(每行一个用户名):\n' +
'▶ 添加:在末尾换行输入新用户名(可用逗号、分号、空格分隔)\n' +
'▶ 删除:直接删掉对应行\n' +
'▶ 清空:提交空文本\n\n' +
'修改后点击“确定”生效。',
current
);
if (input !== null) {
// 支持多种分隔符:换行、逗号、分号、顿号、空格
let newUsers = input.split(/[\n,;、\s]+/)
.map(s => s.trim())
.filter(s => s !== '');
// 去重
newUsers = [...new Set(newUsers)];
setBlockedUsers(newUsers);
hideBlockedUsers();
GM_notification('✅ 屏蔽列表已更新!共 ' + newUsers.length + ' 个用户');
}
});
}
// ---------- 监听动态加载(翻页、AJAX) ----------
function observeThreadList() {
let targetNode = document.getElementById('threadlisttableid');
if (!targetNode) return;
const observer = new MutationObserver(function(mutations) {
let needRefresh = false;
for (let mut of mutations) {
if (mut.addedNodes.length) {
for (let node of mut.addedNodes) {
if (node.nodeType === 1 && node.tagName === 'TBODY' && node.id && node.id.startsWith('normalthread_')) {
needRefresh = true;
break;
}
}
}
if (needRefresh) break;
}
if (needRefresh) {
setTimeout(hideBlockedUsers, 100);
}
});
observer.observe(targetNode, { childList: true, subtree: false });
}
// ---------- 初始化 ----------
function init() {
addMenu();
hideBlockedUsers();
observeThreadList();
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
评分
-
查看全部评分
|