Dither

LiveJournal autoexpand userscript

Aug 25th, 2014
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name          LiveJournal autoexpand
  3. // @description   Autoexpands LJ threads.
  4. // @include       http://*livejournal.com*
  5. // @include       https://*livejournal.com*
  6. // @namespace     http://userscripts.org/scripts/show/112935
  7. // ==/UserScript==
  8.  
  9. if (~window.location.href.indexOf('livejournal.com') && window.location.href.indexOf('__rpc_lj_times_string') === -1)
  10. document.addEventListener('DOMContentLoaded', function(){
  11.  
  12. var EXPAND_CONTAINER_SELECTORS = '.b-tree-root>div>div>div>.b-leaf-footer>ul>.b-leaf-actions-expandchilds>a';
  13. var PLACER_SELECTOR = 'span.js-amount';
  14. var expandall = document.querySelectorAll(PLACER_SELECTOR)[0];
  15. expandall.innerHTML += '<span style="color:tomato">[Click here to expand all...]</span>';
  16. expandall.onclick = function (){
  17.     var commentboxes = document.querySelectorAll(EXPAND_CONTAINER_SELECTORS);
  18.     if (!commentboxes.length) alert('No comments to expand...');
  19.  
  20.     for (var z = commentboxes.length; z--;)
  21.        if (~commentboxes[z].innerText.indexOf('Expand'))
  22.           setTimeout(function(commentbox){ commentbox.click(); }(commentboxes[z]), 1000);
  23. }
  24. }, false);
Add Comment
Please, Sign In to add comment