LiveJournal Comments expander

allows you to automatically expand all comments on the page

  1. // ==UserScript==
  2. // @name LiveJournal Comments expander
  3. // @namespace Whiletruedoend
  4. // @original-script https://gist.github.com/Whiletruedoend
  5. // @original-script https://greasyfork.org/ru/scripts/461690-livejournal-comments-expander
  6. // @version 1.1
  7. // @description allows you to automatically expand all comments on the page
  8. // @author Whiletruedoend
  9. // @match *.livejournal.com/*
  10. // @match livejournal.com/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=livejournal.com
  12. // @grant none
  13. // @license GNU GPLv3
  14. // ==/UserScript==
  15.  
  16. function expandComments(doc){
  17. var comm_style_1 = doc.querySelectorAll('[id^="expand_"], [class^=" mdspost-comment-actions__item mdspost-comment-actions__item--expandchilds "]');
  18.  
  19. if (comm_style_1.length > 0){
  20. for (var i in comm_style_1) {
  21. var elem_1 = comm_style_1[i].lastChild;
  22. if (elem_1 && elem_1.nodeName!="#text"){
  23. elem_1.click();
  24. }
  25. }
  26. } else {
  27. setTimeout(function() {
  28. var comm_style_2 = doc.querySelectorAll('[class^="b-pseudo"]');
  29. if (comm_style_2.length > 0){
  30. for (var j in comm_style_2) {
  31. var elem_2 = comm_style_2[j];
  32. var elem_2_child = elem_2.lastChild;
  33. // && elem_2_child && elem_2_child.nodeValue == "Expand"
  34. if (elem_2 && elem_2_child && elem_2_child.nodeValue=="Expand"){
  35. elem_2.click();
  36. }
  37. }
  38. }
  39. }, 2000);
  40. }
  41. }
  42.  
  43. expandComments(document);