SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. for(var mutation of mutationsList) {
  2.             if (mutation.type == 'childList') {
  3.                 mutation.addedNodes.forEach(function(node){
  4.                     if(node.tagName != "P"){
  5.                         leftPane.innerHTML += 'pepegaClap'
  6.                         return false;
  7.                     }
  8.                    
  9.           //Counter begins here. Get the current number of lines first.
  10.           var lines = document.getElementsByTagName('p').length;
  11.  
  12.           //Second, confirm whether the node insertion was a new line.
  13.           //(Rikai also inserts and removes a node (a div).)
  14.           var isnew = lines - oldlines;
  15.           if ( isnew > 0 ){
  16.               //If it is a new line, do a character count of the line and add it to the running tally.
  17.               var i=lines-1
  18.               var newline = document.getElementsByTagName('p')[i].innerHTML;
  19.               var linechars = newline.length;
  20.               newchars = chars + linechars;
  21.  
  22.               //Make the numbers look nice.
  23.               var charsdisp = newchars.toLocaleString();
  24.               var linesdisp = lines.toLocaleString();
  25.  
  26.               //Print the new counts into the counter.
  27.               jQuery('#counter').text(charsdisp+' / '+linesdisp);
  28.  
  29.               //Get ready for the next line.
  30.               oldlines = lines;
  31.               chars = newchars;
  32.        
  33.               //leftPane.innerHTML += document.getElementsByTagName('p')[0].innerHTML
  34.              
  35.               leftPane.innerHTML += node.innerHTML;
  36.               leftPane.innerHTML += '</br>';
  37.               node.parentNode.removeChild(node)
  38.  
  39.               var LEEWAY = 200; // Amount of "leeway" pixels before latching onto the bottom.
  40.  
  41.               // Some obscene browser shit because making sense is for dweebs
  42.               var b = document.body;
  43.               var offset = b.scrollHeight - b.offsetHeight;
  44.               var scrollPos = (b.scrollTop+offset);
  45.               var scrollBottom = (b.scrollHeight - (b.clientHeight+offset));
  46.  
  47.               // If we are at the bottom, go to the bottom again.
  48.               if (scrollPos >= scrollBottom - LEEWAY) {
  49.                  window.scrollTo(0,document.body.scrollHeight);
  50.               }
  51.  
  52.           }; //This is the end of the "if new line" statement.
  53.                    
  54.                 });
  55.             }
  56.         }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top