Guest User

WIT comment filter script

a guest
Dec 18th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.29 KB | None | 0 0
  1. <script type="text/javascript">
  2. /* Copy this script into the footer of your template at the very bottom of your blog, but before the ending body tag. */
  3. jQuery("li.comment article.contain").each(function (index, comment) {
  4.     var up = parseInt(jQuery(".rating-icons :nth-child(2)", comment).text(), 10);
  5.     var down = parseInt(jQuery(".rating-icons :nth-child(4)", comment).text(), 10);
  6.     var id = jQuery(comment).attr('id');
  7.     /* This checks under which condition a comment should be hidden. In this example:
  8.      *   down >= up + 2  Hide a comment when there are at least two more down votes than up votes
  9.      *   down >= 3       and there are at least three downvotes in total. Both must be true.
  10.      * Adjust this to taste. */
  11.     if (down >= up + 2 && down >= 3) {
  12.        jQuery('<div id="'+id+'-hider"><a href="#" style="display: block; text-decoration: none; color: #989eae; background-color: #111; border: 1px solid #444855; border-top-left-radius: 7px; border-bottom-left-radius: 7px; padding: 5px 0 5px 1em; box-sizing: border-box; width: 100%;" onclick="'+ "jQuery('#"+id+"-hider').css('display', 'none');jQuery('#"+id+"').css('display', 'block');return false;" +'">Comment hidden.</a></p>').insertBefore("#"+id);
  13.         jQuery(comment).css("display", "none");
  14.     }
  15. });
  16. </script>
Add Comment
Please, Sign In to add comment