Greasy Fork is available in English.
torrent page filter
当前为
// ==UserScript==
// @name No More Dramas - TJUPT
// @namespace http://tampermonkey.net/
// @version 0.1.1
// @description torrent page filter
// @author colder
// @match https://*.tjupt.org/torrents.php*
// @match https://*.tju.pt/torrents.php*
// @match https://*.pterclub.com/torrents.php*
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// 要过滤的字符集
const filterChars = ["-GodDramas", "短剧"];
// 需要检查的类名列表
const targetClasses = ['triple_sticky_bg','double_sticky_bg', 'sticky_bg', 'normal_bg', 'sticky_top', 'sticky_normal', 'rowfollow'];
// 检查文本是否包含任意过滤字符
function containsFilterChar(text) {
return filterChars.some(char => text.includes(char));
}
// 隐藏包含过滤字符的<tr>
function hideFilteredTRs() {
targetClasses.forEach(cls => {
document.querySelectorAll(`tr.${cls}`).forEach(tr => {
if (containsFilterChar(tr.textContent)) {
tr.style.display = 'none';
}
});
});
}
// 使用MutationObserver来监视DOM变化
function observeDOMChanges() {
const observer = new MutationObserver((mutations) => {
// 每当DOM变化时,重新应用过滤逻辑
hideFilteredTRs();
});
// 配置观察器:
const config = { childList: true, subtree: true };
// 传入目标节点和观察选项
observer.observe(document.body, config);
}
// 立即执行一次隐藏逻辑,确保在页面加载后立即应用
hideFilteredTRs();
// 设置DOM变化观察器
observeDOMChanges();
})();