How to block posts about Elon Musk (or other custom string) on computer - eviltoast

Using uBlock Origin, you can add your own filter. This filter will block any post with the text “Elon Musk” (not case sensitive), modify as needed.

lemmy.world##div.post-listing:has(span:has-text("/elon musk/i"))

div.post-listing is the element to block
:has(args) returns elements where args evaluate to true
span is the element with the title text
:has-text(needle) returns the element if it has the next needle, supports regex with \needle\ and remove case sensitivity with i

Read more here: https://github.com/gorhill/uBlock/wiki/Procedural-cosmetic-filters

  • madsen@lemmy.world
    link
    fedilink
    English
    arrow-up
    12
    ·
    edit-2
    1 year ago

    You can use the regex: /\bx\b/i

    It’ll catch ‘x’ surrounded by word boundaries (stuff like spaces, dashes/hyphens, commas, etc.) but not ‘x’ with other letters on either side, so it won’t match e.g. “sax” or “boxer”, but it’ll match “x.com” and “Elon’s X” and stuff. It’s probably not perfect though, so use with caution.

    • Mananasi@feddit.nl
      link
      fedilink
      English
      arrow-up
      5
      ·
      1 year ago

      Stuff about X-rays will be filtered, for example. You could probably go a little safer with the regex.

      • madsen@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Yeah, there’s room for improvement. I did say, though, that it probably wasn’t perfect. I’m sure someone more patient than me can come up with a much more effective regex.

    • TDCN@feddit.dk
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 year ago

      It’s sadly not perfect as @Mananasi@feddit.nl also states, and since I like maths related stuff too and science it’ll likely filter out too much stuff. But I appreciate your efforts. An ai algorithm or a community created blacklist is probably the only solution.

      • madsen@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Yeah, good points. I did note, though, that it probably wasn’t perfect. I kinda figured it would probably catch other stuff too but I couldn’t think of anything specific at the time.