// ==UserScript== // @name Twitter/X Bot and Flag Post Hider // @namespace http://tampermonkey.net/ // @version 1.9 // @description Hides posts from suspected bot accounts, users with specific flags, or users with certain keywords in their name. Hover the counter to see who's hidden. // @author CL // @match *://x.com/* // @match *://twitter.com/* // @grant none // @run-at document-idle // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // --- Configuration --- const BOT_USERNAME_PATTERN = /[a-zA-Z].*\d{2,}$/; const HIDE_IF_NAME_INCLUDES = ['🇮🇱', '🇺🇦']; const FORBIDDEN_WORDS = ['democracy', 'ukraine']; const CHECK_INTERVAL = 1000; // --- End Configuration --- // --- Script State --- let hiddenPostCount = 0; const processedPosts = new Set(); const hiddenUsernames = new Set(); // --- UI Elements --- let counterElement; let tooltipElement; /** * Creates UI elements (counter, tooltip) and attaches event listeners. */ function setupUI() { // Create the main counter element counterElement = document.createElement('div'); counterElement.id = 'bot-hider-counter'; Object.assign(counterElement.style, { position: 'fixed', top: '15px', left: '15px', backgroundColor: 'rgba(29, 155, 240, 0.9)', color: 'white', padding: '5px 12px', borderRadius: '15px', zIndex: '10000', fontSize: '14px', fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif', boxShadow: '0 2px 8px rgba(0,0,0,0.2)', userSelect: 'none', cursor: 'pointer', // Add a pointer cursor to indicate it's interactive transition: 'opacity 0.3s ease-in-out' }); document.body.appendChild(counterElement); // Create the tooltip element for showing hidden names tooltipElement = document.createElement('div'); tooltipElement.id = 'bot-hider-tooltip'; Object.assign(tooltipElement.style, { position: 'fixed', top: '55px', // Position it just below the counter left: '15px', display: 'none', // Initially hidden backgroundColor: 'rgba(20, 20, 20, 0.95)', color: 'white', padding: '10px', borderRadius: '8px', zIndex: '9999', fontSize: '13px', fontFamily: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif', boxShadow: '0 2px 8px rgba(0,0,0,0.3)', maxHeight: '400px', overflowY: 'auto', border: '1px solid #333' }); document.body.appendChild(tooltipElement); // Event listener for showing the tooltip on hover counterElement.addEventListener('mouseenter', () => { if (hiddenUsernames.size === 0) { tooltipElement.innerHTML = 'No accounts hidden yet.'; } else { // Format the list of names from the Set const userList = [...hiddenUsernames].map(name => `