No More Dramas - TJUPT/PTer

torrent page filter

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         No More Dramas - TJUPT/PTer
// @namespace    http://tampermonkey.net/
// @version      0.1.3
// @description  torrent page filter
// @author       colder
// @match        https://*.tjupt.org/torrents.php*
// @match        https://*.tju.pt/torrents.php*
// @match        https://*.pterclub.com/torrents.php*
// @match        https://*.pterclub.net/torrents.php*
// @license MIT
// ==/UserScript==


(function() {
    'use strict';
    const filterChars = ["-GodDramas", "短剧"];
    
    function containsFilterChar(text) {
        return filterChars.some(char => text.includes(char));
    }
    
    function hideFilteredTRs() {
        const torrentsTable = document.querySelector('.torrents') || 
                             document.querySelector('table.torrents') ||
                             document.querySelector('table');
        
        if (torrentsTable) {
            torrentsTable.querySelectorAll('tr').forEach(tr => {
                if (containsFilterChar(tr.textContent)) {
                    tr.style.display = 'none';
                }
            });
        }
    }
    
    function observeDOMChanges() {
        const observer = new MutationObserver((mutations) => {
            hideFilteredTRs();
        });
        const config = { childList: true, subtree: true };
        observer.observe(document.body, config);
    }
    
    // Wait for page load
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', hideFilteredTRs);
    } else {
        hideFilteredTRs();
    }
    
    observeDOMChanges();
})();