Day: July 10, 2017

Hide Techdirt Comments

Updated 2018-03-06: Fixed case where usernames inside links were not being blocked.


Updated 2018-03-04: Added function to hide long subject lines, because some trolls like to write manifesto-length gibberish in the Subject: line.

There is now a maxSubjectLength variable (default value: 50). Any subject line exceeding that length will be hidden. If you reply to a post with a subject line exceeding that length, your reply's subject line will default to "Re: tl;dr".


Updated 2017-07-12: Added @include.


In my previous post, I mentioned that I spend too much of my life responding to trolls on Techdirt.

With that realization, I whipped up a quick Greasemonkey/Tampermonkey script to block all posts from specified usernames.

// ==UserScript==
// @name          Hide Techdirt Comments
// @namespace     http://corporate-sellout.com
// @description	  Hide comments on Techdirt, based on user and comment length.
// @include       https://www.techdirt.com/articles/*
// @include       https://www.techdirt.com/blog/*
// @require       https://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==

// Maximum length of Subject line before hiding contents
var maxSubjectLength = 50;

// List of users whose comments you want to hide -- collect 'em all!
var ignoreMe = [
  'Anonymous Coward',
  'MyNameHere'
];

// Set "Subject:" line in reply to "Re: tl;dr"
var clearInput = function() {
  $('#replysubject').val('Re: tl;dr');
};

// Check comment to see if poster matches anyone in ignoreMe.
// If yes, remove the comment and return true.
// If no, return false.
function checkComment(cmt) {
  var name = $('.commentname > div > :first-child', cmt).text().trim();

  for(var i=0; i<ignoreMe.length; i++) {
    if(ignoreMe[i] == name) {
      cmt.text('removed');
      return true;
    }
  }
  return false;
}

// If subject exceeds maxSubjectLength, remove it.
function trimSubject(cmt) {
  var subject = $('.commentsubject', cmt),
    len = subject.text().length;

  if(len > maxSubjectLength) {
    subject.empty();

    // Find "Reply" button for this comment
    // and bind clearInput() to its click() event.
    var cmtId = cmt.attr('id').substr(1),
      replyLink = $('#cmmt_link_' + cmtId);

    replyLink.click(clearInput);
  }
}

$('.cmt').each(function() {
  var cmt = $(this),
    removed = checkComment(cmt);

  if(!removed) {
    trimSubject(cmt);
  }
});

License

I'm not a lawyer, but my opinion as a programmer is that this script is too short, simple, and obvious to be copyrightable. As such, I claim no copyright, and offer no license, because none is needed. Use it however you want, with the standard disclaimer that it comes with absolutely no warranty.

It's possible I may revise the script at a later date (see below), in which case I'll probably use the MIT license.

Further Thoughts

This is a blunt instrument; it took about five minutes to write. It lacks subtlety and nuance.

Blocking all anonymous posters on Techdirt is not an ideal solution; most anons aren't trolls. (Most trolls, however, are anons.) I apologize to all the innocent anons blocked by this script.

I could make the script more precise. Techdirt's trolls are creatures of habit with certain noticeable verbal tics (more on that below); if I had a good parser, I think I could whip up a scoring system that could recognize troll posts with a high degree of accuracy.

The question is, how much time do I want to spend on that?

On the one hand, "five minutes in a text editor" is the appropriate amount of time for dealing with forum trolls. Anything else seems like more effort and attention than they deserve.

On the other hand, it's a potentially interesting project, I've always wanted to spend some time studying natural language processing, and any programming project is time well-spent if it teaches you a new skill.

So I haven't decided yet. Here's the script as it stands, in its initial, blunt-instrument-that-took-five-minutes form. If I update the script, I'll update this post.

Chip Tips

Lastly, as I can no longer see anonymous posts, this means I will likely have to give up my beloved sockpuppet, Chip, the man who hates all government regulations and loves to eat leaded paint chips. To anyone and everyone else who wants to keep the spirit of Chip alive, you have my blessing to post under his name.

A few tips on how to write as Chip:

  • Never use the backspace key.
  • Remember to add random Capital Letters and "quotation marks" to your posts, in Places where they "don't" make Sense!
  • Most sentences should end with Exclamation Points!
  • I told you So!
  • I have "lots" of Solutions! So many I can't Name a single "one"!
  • Sycophantic Idiots!
  • Every Nation eats the Paint chips it Deserves!

Boy, my regular readers are going to have no fucking idea what I'm talking about in this post.

Come back tomorrow; I plan on having a post about online privacy that should be a little less niche.