Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(var mutation of mutationsList) {
- if (mutation.type == 'childList') {
- mutation.addedNodes.forEach(function(node){
- if(node.tagName != "P"){
- leftPane.innerHTML += 'pepegaClap'
- return false;
- }
- //Counter begins here. Get the current number of lines first.
- var lines = document.getElementsByTagName('p').length;
- //Second, confirm whether the node insertion was a new line.
- //(Rikai also inserts and removes a node (a div).)
- var isnew = lines - oldlines;
- if ( isnew > 0 ){
- //If it is a new line, do a character count of the line and add it to the running tally.
- var i=lines-1
- var newline = document.getElementsByTagName('p')[i].innerHTML;
- var linechars = newline.length;
- newchars = chars + linechars;
- //Make the numbers look nice.
- var charsdisp = newchars.toLocaleString();
- var linesdisp = lines.toLocaleString();
- //Print the new counts into the counter.
- jQuery('#counter').text(charsdisp+' / '+linesdisp);
- //Get ready for the next line.
- oldlines = lines;
- chars = newchars;
- //leftPane.innerHTML += document.getElementsByTagName('p')[0].innerHTML
- leftPane.innerHTML += node.innerHTML;
- leftPane.innerHTML += '</br>';
- node.parentNode.removeChild(node)
- var LEEWAY = 200; // Amount of "leeway" pixels before latching onto the bottom.
- // Some obscene browser shit because making sense is for dweebs
- var b = document.body;
- var offset = b.scrollHeight - b.offsetHeight;
- var scrollPos = (b.scrollTop+offset);
- var scrollBottom = (b.scrollHeight - (b.clientHeight+offset));
- // If we are at the bottom, go to the bottom again.
- if (scrollPos >= scrollBottom - LEEWAY) {
- window.scrollTo(0,document.body.scrollHeight);
- }
- }; //This is the end of the "if new line" statement.
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement