// ==UserScript==
// @name          ignoreUserXenforo
// @namespace      sinodefenceforum
// @match      
https://www.sinodefenceforum.com/*
// ==/UserScript==
// Define the username of the user whose posts you want to hide
var userToHide = 'User'; //Replace 'User' with the username you want to block
// Get all the posts on the page
var posts = document.querySelectorAll('.message-inner .bbWrapper, .message-inner blockquote');
// Loop through each post
posts.forEach(function(post) {
    // Check if it's a regular post or a blockquote
    if (post.tagName.toLowerCase() === 'blockquote') {
        // Handle blockquotes
        var authorElement = post.querySelector('.bbCodeBlock-title a');
        if (authorElement && authorElement.textContent.trim() === (userToHide + " said:")) {
            // Hide the content of the blockquote
            var blockquoteContent = post.querySelector('.bbCodeBlock-content');
            blockquoteContent.style.display = 'none';
            // Add a message indicating the content is hidden
            var messageNode = document.createElement('div');
            messageNode.classList.add('messageNotice', 'messageNotice--nested', 'messageNotice--ignored');
            messageNode.innerHTML = 'You are ignoring content by this member. <a href="javascript:void(0)" class="showIgnoredLink js-showIgnored" data-xf-init="tooltip" data-original-title="Show hidden content">Show ignored content</a>';
            // Append the message after the hidden content
            blockquoteContent.parentNode.insertBefore(messageNode, blockquoteContent.nextSibling);
            // For blockquotes, create the "Show hidden content" link
            var showContentLink = messageNode.querySelector('.showIgnoredLink');
            // Add click event listener to reveal the hidden content
            showContentLink.addEventListener('click', function() {
                blockquoteContent.style.display = ''; // Show the hidden content
                messageNode.style.display = 'none'; // Hide the message
            });
        }
    } else {
        // Handle regular posts
        var authorElement = post.closest('.message').querySelector('.username');
        if (authorElement && authorElement.textContent.trim() === userToHide) {
            // Hide the content of the post
            post.style.display = 'none';
            // Add a message indicating the content is hidden
            var messageNode = document.createElement('div');
            messageNode.classList.add('messageNotice', 'messageNotice--nested', 'messageNotice--ignored');
            messageNode.innerHTML = 'You are ignoring content by this member. <a href="javascript:void(0)" class="showIgnoredLink js-showIgnored" data-xf-init="tooltip" data-original-title="Show hidden content">Show ignored content</a>';
            // Create the "Show hidden content" link
            var showContentLink = messageNode.querySelector('.showIgnoredLink');
            // Add click event listener to reveal the hidden content
            showContentLink.addEventListener('click', function() {
                post.style.display = ''; // Show the hidden content
                showContentLink.style.display = 'none'; // Hide the "Show hidden content" link
            });
            // Append the link after the hidden content
            post.parentNode.insertBefore(messageNode, post.nextSibling);
        }
    }
});