Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Hide Posts from Specific Users on QBN Topics
- // @namespace http://tampermonkey.net/
- // @version 0.3
- // @description Automatically hide posts from specific users on qbn.com topics
- // @author You
- // @match https://www.qbn.com/topics/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- // List of users to ignore
- const ignoredUsers = ['user1', 'user2', 'user3']; // Add more users here as needed
- // Function to hide posts from ignored users
- function hidePosts() {
- console.log("Running hidePosts..."); // Debugging output
- document.querySelectorAll('.reply').forEach((post) => {
- const usernameElement = post.querySelector('.user');
- if (usernameElement) {
- const username = usernameElement.textContent.trim();
- if (ignoredUsers.includes(username)) {
- // Hide the post if the user is in the ignored list
- console.log("Hiding post from user:", username); // Debugging output
- post.style.display = 'none';
- }
- }
- });
- }
- // Use MutationObserver to watch for dynamically added posts
- const observer = new MutationObserver((mutationsList, observer) => {
- for (let mutation of mutationsList) {
- if (mutation.type === 'childList') {
- hidePosts(); // Re-run hidePosts whenever new posts are added
- }
- }
- });
- // Configure the observer to watch for changes in the reply section
- const config = { childList: true, subtree: true };
- const replyContainer = document.querySelector('.replies'); // Adjust if necessary
- if (replyContainer) {
- console.log("Reply container found. Setting up MutationObserver...");
- observer.observe(replyContainer, config);
- } else {
- console.log("Reply container not found!"); // Debugging output
- }
- // Also run the function on initial page load
- hidePosts();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement