Empeopled direct comment link

Adds a direct link to each comment

  1. // ==UserScript==
  2. // @name Empeopled direct comment link
  3. // @namespace empeopled
  4. // @version 0.2
  5. // @description Adds a direct link to each comment
  6. // @author Ludiko
  7. // @match http*://*.empeopled.com/*
  8. // @require http://code.jquery.com/jquery-2.1.4.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. var commentNumber = 0;
  13.  
  14. function checkComments() {
  15. var comment = $('[id^=comment_actions_]');
  16. if(comment.length == commentNumber) {
  17. setTimeout(checkComments, 400);
  18. } else {
  19. comment.each(function () {
  20. var id = $(this).attr('id').split('_')[2];
  21. var contextual = $(this).find('.contextual');
  22. if (contextual.find('#comment_link_' + id).length == 0 ) {
  23. contextual.append('<a href="https://empeopled.com/c/' + id + '" title="permalink" id="comment_link_' + id + '"><i class="fa fa-link"></i></a>');
  24. }
  25. })
  26. setTimeout(checkComments, 5000);
  27. }
  28. }
  29.  
  30. $(window).scroll(function () {
  31. if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
  32. commentNumber = $('[id^=comment_actions_]').length;
  33. checkComments();
  34. }
  35. });
  36.  
  37. checkComments();