Advertisement
Guest User

hide-slashdot-anonymous-coward-comments

a guest
Jun 26th, 2015
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name          Nuke anonymous cowards
  3. // @description   Since people post so offensively so often, let's just hide the anons
  4. // @include       http://slashdot.org/*
  5. // @include       http://*.slashdot.org/*
  6. // @include       https://slashdot.org/*
  7. // @include       https://*.slashdot.org/*
  8. // @grant         none
  9. // ==/UserScript==
  10.  
  11.  
  12. /************************************************
  13.  *  Stash some info about comments
  14.  ************************************************/
  15. var arrayOfCommentDivs = [];
  16. var toRemoveComment = [];
  17. var toRemoveReplyButtons = [];
  18.  
  19. /************************************************
  20.  *  Fetch the list of anonymous posters
  21.  ************************************************/
  22. var elements = document.getElementsByClassName("by");
  23. for(var i = 0; i < elements.length; i++) {
  24.   var text = elements[i].innerHTML.toString();
  25.   if(text.contains("Anonymous Coward")) {
  26.     var theComment = elements[i].parentElement.parentElement.parentElement;
  27.     arrayOfCommentDivs.push( theComment );
  28.     toRemoveComment.push( theComment.getElementsByClassName("commentBody")[0] );
  29.     toRemoveReplyButtons.push( theComment.getElementsByClassName("commentSub")[0] );
  30.   }
  31. }
  32.  
  33. /************************************************
  34.  *  Act on the list of anonymous posters
  35.  ************************************************/
  36. for(var i = toRemoveComment.length - 1; i >= 0; i--) {
  37.   toRemoveComment[i].style.display      = "none";
  38.   toRemoveReplyButtons[i].style.display = "none";
  39.   arrayOfCommentDivs[i].style.display   = "none";
  40.   // do something more advanced if you wish  (arrayOfCommentDivs[i])
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement