// ==UserScript== // @name Hide Users // @namespace http://tampermonkey.net/ // @version 1.0 // @description Hide all children of specified classes except for `.subject` and .info and toggle visibility on click // @include https://www.mikrocontroller.net/topic/* // @grant GM_addStyle // ==/UserScript== (function() { 'use strict'; // List of class names const classNames = ['post-userid-27772', 'user2', 'user3']; // Replace with actual class names // Apply the initial styles GM_addStyle(` ${classNames.map(className => ` .${className}.GMhidden > * { display: none; /* Hide all direct children when the hidden class is applied */ } .${className}.GMhidden .subject, .${className}.GMhidden .info { display: block; /* Ensure .subject and .info are displayed */ } `).join('')} `); // Function to toggle the hidden class on click function toggleVisibility(event) { event.currentTarget.classList.toggle('GMhidden'); // Toggle the hidden class on the parent } // Add click event listener to each class classNames.forEach(className => { const elements = document.getElementsByClassName(className); Array.from(elements).forEach(element => { element.classList.add('GMhidden'); // Add hidden class initially element.addEventListener('click', toggleVisibility); }); }); })();