Highlight anon replies

make it so that mods comments show up with the little line on the left side

  1. // ==UserScript==
  2. // @name Highlight anon replies
  3. // @namespace metafilter
  4. // @version 0.1
  5. // @description make it so that mods comments show up with the little line on the left side
  6. // @author jacalata@gmail.com
  7. // @grant none
  8. // @include *://ask.metafilter.com/*
  9. // ==/UserScript==
  10. /* jshint -W097 */
  11. 'use strict';
  12.  
  13. // requested in a comment: http://metatalk.metafilter.com/19656/Where-are-you-located-Where-are-you-located-Where-are-you-located#801909
  14.  
  15. var comment_identifier = 'class="comments"';
  16. var indicator_text = "From the OP";
  17. var allowed_posters = ["cortex", "restless_nomad", "taz", "LobsterMitten", "goodnewsfortheinsane", "Eyebrows McGee", "pb", "vacapinta", "jessamyn"]; //http://faq.metafilter.com/#33 + jessamyn for historical threads
  18.  
  19. var comments = document.getElementsByClassName("comments");
  20.  
  21. var select_this_comment = function(cmt){
  22. if (cmt.innerText.toLowerCase().indexOf(indicator_text.toLowerCase()) < 0) { //console.log("not by OP");
  23. return false; }
  24. for (var i in allowed_posters){
  25. if (cmt.children[1].innerText.toLowerCase().indexOf(allowed_posters[i].toLowerCase()) >= 0) {
  26. console.log("Anon update posted by", allowed_posters[i]);
  27. return cmt;
  28. }
  29. // console.log(allowed_posters[i], "not found");
  30. }
  31. return false; //didn't find a mod name
  32. };
  33.  
  34. var responses = [];
  35. for (var i =0; i<comments.length; i++) {
  36. var comment = comments[i];
  37. // console.log("working on ", comment);
  38. if (!comment.innerHTML) { continue; }
  39. if (comment.className != "comments") {
  40. //console.log("bad element: ", comment);
  41. continue; }
  42. else {
  43. //console.log("comment found", comment);
  44. if (select_this_comment(comment)){
  45. console.log("found response ", responses.length+1);
  46. responses[responses.length] = comment;
  47. }
  48. }
  49. }
  50. console.log("found:", responses);
  51. for (var j = 0; j < responses.length; j++){
  52. console.log(responses[j]);
  53. responses[j].className += " bestleft"
  54. }