Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
how to implement or improve a "killfile" for stack exchange?

SE doesn't have any killfile capability to hide posts by trolls and other abusive people. And, unfortunately, blocking such trolls can't be done with CSS hacks alone (because there's nothing in the CSS which distinguishes a troll from a normal person). Blocking trolls need to be done by matching their usernames in the actual text of the post or comment, so it requires javascript and a userscript manager like grease/tamper/violent-monkey.

I've come up with the following (based on the same code I've used for other sites to hide advertorial garbage hiding amongst actual articles - no obvious CSS differences, but with identifiable author By-Lines), which mostly works but it doesn't interact perfectly with posts that have lots of comments - it breaks the "Show more comments" link. Not a huge problem, but I'd rather it didn't do that.

Update: Actually, it breaks the "Show more" link no matter how many comments there are, a bigger problem than I thought.

Does anyone have any idea what's causing it to do that, or how to fix it? Is it the div class for comments div.comment-text.js-comment-text-and-form that I'm targeting?

// ==UserScript==
// @name         Killfile Userscript for Stack Exchange
// @namespace    MonkeyScripts
// @version      0.1
// @description  Hide posts by abusive/irritating users
// @author       cas
// @match        https://*.stackexchange.com/*
// @match        https://*.stackoverflow.com/*
// @match        https://*.serverfault.com/*
// @match        https://*.superuser.com/*
// @match        https://*.askubuntu.com/*
// @require      https://code.jquery.com/jquery-2.1.0.min.js
// @grant        none
// ==/UserScript==

// hide posts and comments by particular authors

(function() {
      let Trolls = ['Ned Trollton','Angry Stalker','loser12345'];

      let elements = ['li.comment',
                      'div.answercell.post-layout--right',
                      'div.postcell.post-layout--right'];

      for (let i = 0; i < Trolls.length; i++) {
          for (let j = 0; j < elements.length; j++) {
              $(elements[j] + ":contains(" + Trolls[i] + ")").hide();
          }
    }
})();
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!