Emacs China 作为国内少数中文优质论坛,混的时间久了难免会对某些用户的帖子有些反感,虽然论坛自身有屏蔽的功能[1],但仅仅是把内容用「ignored content」来替代,帖子本身还在,没法直接把帖子直接隐藏掉,因此写了个油猴脚本来做这件事。
安装地址:https://greasyfork.org/en/scripts/429688-emacs-china-user-blocker
// ==UserScript==
// @name emacs-china user blocker
// @namespace https://liujiacai.net/
// @match https://emacs-china.org/
// @grant none
// @version 1.0
// @author https://github.com/jiacai2050
// @description Emacs-China 论坛,屏蔽指定用户的帖子
// @icon https://emacs-china.org/uploads/default/optimized/2X/d/dd05943671ee57856f9d7fa7ba6497f31bfcd332_2_180x180.png
// ==/UserScript==
// user ids your want to block
const blockedUsers = [];
const prefix = 'https://emacs-china.org/u/';
let seenPostCount = 0;
function removeBlockedPosts() {
const allPosts = document.querySelectorAll('td.posters a');
console.log(allPosts.length);
if (seenPostCount >= allPosts.length) {
// console.log('already removed, return directly');
return;
}
const oldLength = seenPostCount;
seenPostCount = allPosts.length;
for (let i=oldLength;i<allPosts.length;i++) {
const post = allPosts[i];
const url = post.href;
for (blocked of blockedUsers) {
const userLink = prefix + blocked;
if (url === userLink) {
const tr = post.parentNode.parentNode;
const titleLink = tr.firstElementChild.firstElementChild.firstElementChild;
console.log(`remove post: ${titleLink.textContent}, url: ${titleLink.href}, by ${blocked}`);
tr.remove();
}
}
}
}
window.addEventListener('wheel', removeBlockedPosts);
window.addEventListener('load', removeBlockedPosts);
引用链接
[1]
有屏蔽的功能: https://emacs-china.org/t/topic/11765