He was a bronze Torb main

  • peppersky [he/him, any]@hexbear.net
    link
    fedilink
    English
    arrow-up
    13
    ·
    2 days ago

    Please add a word filter so I can filter out these stupid nonsense posts about Musk please I don’t give a shit about him personally and you really shouldn’t care either

    • BountifulEggnog [she/her]@hexbear.net
      link
      fedilink
      English
      arrow-up
      4
      ·
      2 days ago

      With a bit of fiddling deepseek gave me this tamper monkey script, appears to work on my end:

      spoiler
      // ==UserScript==
      // @name         Lemmy Post Filter
      // @namespace    http://tampermonkey.net/
      // @version      0.1
      // @description  Remove Lemmy posts containing specific keywords in their titles
      // @author       Deepseek
      // @match        https://hexbear.net/*
      // @match        https://*.hexbear.net/*
      // @match        https://lemmygrad.ml/*
      // @match        https://*.lemmygrad.ml/*
      // @grant        none
      // ==/UserScript==
      
      (function() {
          'use strict';
      
          // Add your keywords here (case insensitive)
          const KEYWORDS = [
              'elon',
              'musk'
              // Add more keywords as needed
          ];
      
          // Function to check if title contains any of the keywords
          function containsKeyword(title) {
              if (!title) return false;
              const lowerTitle = title.toLowerCase();
              return KEYWORDS.some(keyword => lowerTitle.includes(keyword.toLowerCase()));
          }
      
          // Function to process posts
          function filterPosts() {
              const posts = document.querySelectorAll('.post-listing.mt-2');
      
              posts.forEach(post => {
                  const titleElement = post.querySelector('.d-inline-block');
                  if (titleElement) {
                      const titleText = titleElement.textContent || titleElement.innerText;
                      if (containsKeyword(titleText)) {
                          // Remove the post
                          post.style.display = 'none';
      
      
                          // Find and remove the HR after this post
                          const nextElement = post.nextElementSibling;
                          if (nextElement && nextElement.tagName === 'HR') {
                              nextElement.style.display = 'none';
                          }
      
                          console.log('Removed post with title:', titleText);
                      }
                  }
              });
          }
      
          // Run initially
          filterPosts();
      
          // Observe DOM changes for infinite scroll or dynamic content loading
          const observer = new MutationObserver(function(mutations) {
              filterPosts();
          });
      
          observer.observe(document.body, {
              childList: true,
              subtree: true
          });
      })();