97

He was a bronze Torb main

you are viewing a single comment's thread
view the rest of the comments
[-] BountifulEggnog@hexbear.net 4 points 6 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
    });
})();
[-] peppersky@hexbear.net 2 points 6 days ago

Damn if that works that'd be real useful, thanks a lot, I'm too stupid to do things like that even with AI

[-] BountifulEggnog@hexbear.net 6 points 6 days ago

You aren't stupid for not knowing how to do something penguin-love Hope it works for you, I can try to help you install it if you need.

[-] peppersky@hexbear.net 4 points 5 days ago

cri

Is that that revolutionary kindness I heard so much about...

Thank you so much, installing Userscripts does fall within my skill range tho. Thank you anyway for the offer

this post was submitted on 02 Apr 2025
97 points (99.0% liked)

chapotraphouse

13765 readers
900 users here now

Banned? DM Wmill to appeal.

No anti-nautilism posts. See: Eco-fascism Primer

Slop posts go in c/slop. Don't post low-hanging fruit here.

founded 4 years ago
MODERATORS