Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - function want(selector) {
 - return document.documentElement.querySelectorAll(selector);
 - }
 - function loadAll(thendo, timeout) {
 - var loader = want('[data-action="more-posts"]');
 - if(loader[0].parentElement.style.display!="none"){
 - loader[0].click();
 - setTimeout(function(){loadAll(thendo,timeout);},timeout||1000);
 - } else {
 - if(thendo){thendo();};
 - }
 - }
 - function posts() {
 - return want('div.post-body');
 - }
 - function postID(post) {
 - return Number(post.querySelector('a.time-ago').href.replace(/.*\/#comment-/,""));
 - }
 - function sortedPosts () {
 - var postlist = [];
 - posts().forEach(function(x){postlist.push([postID(x),x]);});
 - return postlist.sort().map(function(x) {return x[1];});
 - }
 - function collapser(node) {
 - var res = document.createElement("div");
 - res.appendChild(document.createTextNode("↸"));
 - res.onclick = function(){
 - if (node.style.display == "none"){
 - node.style.display = "block";
 - }else{
 - node.style.display = "none";
 - }
 - };
 - res.style.fontSizeAdjust = 2;
 - res.style.margin = "2em";
 - res.style.backgroundColor = "#EFEFFF";
 - return res;
 - }
 - function appendSortedPosts() {
 - var holder = document.createElement("div");
 - holder.style.margin = "2em";
 - sortedPosts().forEach(function(x){
 - var y = holder.appendChild(document.createElement("div"));
 - y.innerHTML = x.innerHTML;
 - var name = x.querySelector('a.time-ago').href.replace(/.*#/,"");
 - x.id = name;
 - x.name = name;
 - x.setAttribute("name", name);
 - x.setAttribute("id", name);
 - y.querySelectorAll('a').forEach(function(z){
 - z.href = "#" + name;
 - });
 - y.onclick = function() {
 - console.log(postID(x));
 - document.documentElement.
 - querySelectorAll('div.post-body').
 - forEach(function(n){
 - if(postID(n)>=postID(x)){
 - n.style.backgroundColor = '#EEFFF7';
 - }else{
 - n.style.backgroundColor = '#FFFFFF';
 - }
 - });
 - };
 - });
 - document.body.appendChild(collapser(holder));
 - document.body.appendChild(holder);
 - document.body.appendChild(collapser(holder)).scrollIntoView();
 - }
 - function loadAndAppendSorted() {
 - loadAll(appendSortedPosts);
 - }
 - loadAndAppendSorted();
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment