SHARE
TWEET

Truncate mefi comments

a guest Jul 30th, 2018 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:(function(){
  2. // Toggle the visibility of all but the last ten comments.
  3.  
  4. var tCcomments = document.getElementsByClassName('comments'); // Gets a list of all the comment divs
  5. var toggle = tCcomments[0].style.display=='none'?'':'none'; // Checks if the first comment is hidden
  6.  
  7. for (var i = 0; i < tCcomments.length - 13; i++) {
  8.     //-13 to leave the last ten comments visible, and because there are three extra comment class elements at the end of the page
  9.  
  10.     try {
  11.    
  12.         // Toggle the comment visibility
  13.         tCcomments[i].style.display=toggle; // Comment
  14.         tCcomments[i].nextSibling.style.display=toggle; // First <br /> after comment
  15.         tCcomments[i].nextSibling.nextSibling.style.display=toggle; // Second <br /> after comment
  16.  
  17.     } catch (e) {
  18.  
  19.         console.log(e);
  20.         continue;
  21.  
  22.     }
  23.  
  24. };
  25.  
  26. $(window).resize() // Forcing scroll refresh
  27. document.getElementsByName('commentpreview')[0].scrollIntoView(true); // Jump to the comment form
  28.  
  29. })();
  30.  
  31. // Minified version:
  32.  
  33. javascript:(function(){for(var e=document.getElementsByClassName("comments"),n="none"==e[0].style.display?"":"none",t=0;t<e.length-13;t++)try{e[t].style.display=n,e[t].nextSibling.style.display=n,e[t].nextSibling.nextSibling.style.display=n}catch(e){console.log(e);continue}$(window).resize(),document.getElementsByName("commentpreview")[0].scrollIntoView(!0)}());
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top