您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Hide Reddit posts on /r/all if they match specific keywords in the title (supports infinite scroll)
- // ==UserScript==
- // @name Reddit /r/all Filter by Keywords (Robust)
- // @namespace http://tampermonkey.net/
- // @version 6.0
- // @description Hide Reddit posts on /r/all if they match specific keywords in the title (supports infinite scroll)
- // @match https://www.reddit.com/r/all*
- // @grant none
- // @run-at document-idle
- // ==/UserScript==
- (function () {
- 'use strict';
- // ADD YOUR BLOCKED POST KEYWORDS HERE
- const blockedKeywords = [
- 'trump',
- 'kardashian',
- 'elon',
- 'crypto',
- 'taylor swift'
- ];
- function filterPosts() {
- const titles = document.querySelectorAll('faceplate-screen-reader-content');
- titles.forEach(titleEl => {
- const text = titleEl.textContent.toLowerCase().trim();
- const post = titleEl.closest('shreddit-post');
- if (!post || post.dataset.filtered === 'true') return;
- if (blockedKeywords.some(keyword => text.includes(keyword))) {
- post.style.display = 'none';
- post.dataset.filtered = 'true';
- console.log(`[Filtered]: ${text}`);
- }
- });
- }
- // Observe DOM mutations for endless scroll
- const observer = new MutationObserver(filterPosts);
- observer.observe(document.body, { childList: true, subtree: true });
- // Fallback for missed posts
- setInterval(filterPosts, 1500);
- // Initial run
- window.addEventListener('load', filterPosts);
- })();