Advertisement
Kinu-chan

34P showreplies Booster

Mar 18th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. // ==UserScript==
  2. // @name 34P showreplies Booster
  3. // @namespace 34P showreplies Booster
  4. // @author Unkown Anonymous
  5. // @contributor Kinu
  6. // @description Boost showreplies() function on 34pchan.org
  7. // @include http://*34pchan.org/*
  8. // ==/UserScript==
  9.  
  10. var script = document.createElement('script');
  11. script.setAttribute("type", "application/javascript");
  12. script.textContent = "showreplies = function(root) {"+
  13. " if (!Settings.showReplies()) return;"+
  14. " root = root ? root : 'body';"+
  15. " $(root).find('.replieslist').remove();"+
  16. " var replies = [];"+
  17. " var messages = [];"+
  18. " $(root).find('.postmessage').each(function(index, element) {"+
  19. " var node = $(this).parents('.postnode').first();"+
  20. " var postlink = node.find('span.reflink').find('a').first().attr('href');"+
  21. " replies[postlink] = [];"+
  22. " messages.push($(this));"+
  23. " });"+
  24. " for(j = messages.length - 1; j != 0; j--) {"+
  25. " var message = messages[j];"+
  26. " var node = message.parents('.postnode').first();"+
  27. " var postlink = node.find('span.reflink').find('a').first().attr('href');"+
  28. " message.find('a').each(function(index, element) {"+
  29. " var href = $(this).attr('href');"+
  30. " if(replies[href]!=null)"+
  31. " {"+
  32. " replies[href].push(postlink);"+
  33. " }"+
  34. " });"+
  35. " var myreplies = $.unique(replies[postlink]);"+
  36. " if (myreplies.length > 0) {"+
  37. " var repliesString = '<div \class=\"replieslist\"><br />'+_.replies+': ';"+
  38. " for (i = 0; i < myreplies.length; i++) {"+
  39. " var replypostlink = myreplies[i];"+
  40. " var replypostid = replypostlink.split('#')[1];"+
  41. " repliesString += '<a href=\"'+replypostlink+'\" onclick=\"javascript:highlight(\\''+replypostid+'\\', true);\">&gt;&gt;'+replypostid+\"</a>\";"+
  42. " if (i != myreplies.length - 1) repliesString += ', ';"+
  43. " }"+
  44. " node.find('.postmessage').append(repliesString);"+
  45. " PostPreviews.setupPreviews(node.find('.replieslist').get());"+
  46. " }"+
  47. " }"+
  48. "};";
  49. document.body.appendChild(script);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement