HLTV.ORG COLLAPSE COMMENTS

Add comment tree collapsing button to comments

  1. // ==UserScript==
  2. // @name HLTV.ORG COLLAPSE COMMENTS
  3. // @namespace https://greasyfork.org/pl/users/10243-pexu
  4. // @version 1.0.0
  5. // @description Add comment tree collapsing button to comments
  6. // @author peXu
  7. // @match http://www.hltv.org/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. //jQuery('.centerFade>div>div>div>.header2').prepend("<a class='us-px' style='cursor:pointer'>[-]</a> | "); // only top level comments
  12. jQuery('.header2').prepend("<a class='us-px' style='cursor:pointer'>[-]</a> | "); // all comments
  13.  
  14. jQuery(function() {
  15. jQuery('.us-px').click( function() {
  16. jQuery(this).toggleClass('us-collapsed');
  17. if (jQuery(this).hasClass('us-collapsed')) { // collapsing
  18. jQuery(this).text("[+]");
  19. jQuery(this).parents('div').eq(2).children().not('.header').hide();
  20. } else { // expanding
  21. jQuery(this).text("[-]");
  22. jQuery(this).parents('div').eq(2).children().not('.header').show();
  23. }
  24. });
  25. });