diff --git a/sox.features.js b/sox.features.js index e370a93..1645b56 100644 --- a/sox.features.js +++ b/sox.features.js @@ -563,14 +563,17 @@ if (!sox.user.loggedIn) return; function addReplyLinks() { - $('.comment').each(function() { - if (!$(this).find('.soxReplyLink').length) { //if the link doesn't already exist - if (sox.user.name !== $(this).find('.comment-text a.comment-user').text()) { //make sure the link is not added to your own comments - $(this).find('.comment-text').css('overflow-x', 'hidden'); - $(this).find('.comment-text .comment-body').append(''); + // Delay needed because of https://github.com/soscripted/sox/issues/379#issuecomment-460001854 + setTimeout(() => { + $('.comment').each(function () { + if (!$(this).find('.soxReplyLink').length) { //if the link doesn't already exist + if (sox.user.name !== $(this).find('.comment-text a.comment-user').text()) { //make sure the link is not added to your own comments + $(this).find('.comment-text').css('overflow-x', 'hidden'); + $(this).find('.comment-text .comment-body').append(''); + } } - } - }); + }); + }, 100); } $(document).on('click', 'span.soxReplyLink', function() { @@ -2443,7 +2446,8 @@ // Description: Only show the comment actions (flag/upvote) when hovering over a comment function addCSS() { - $('.comment').addClass('sox-onlyShowCommentActionsOnHover'); + // Delay needed because of https://github.com/soscripted/sox/issues/379#issuecomment-460001854 + setTimeout(() => $('.comment').addClass('sox-onlyShowCommentActionsOnHover'), 100); } $(document).on('sox-new-comment', addCSS); diff --git a/sox.user.js b/sox.user.js index 4e0b708..d9baa06 100644 --- a/sox.user.js +++ b/sox.user.js @@ -3,7 +3,7 @@ // @namespace https://github.com/soscripted/sox // @homepage https://github.com/soscripted/sox // @homepageURL https://github.com/soscripted/sox -// @version 2.3.30 DEV +// @version 2.3.31 DEV // @description Extra optional features for Stack Overflow and Stack Exchange sites // @contributor ᴉʞuǝ (https://stackoverflow.com/users/1454538/, https://github.com/mezmi) // @contributor ᔕᖺᘎᕊ (https://stackexchange.com/users/4337810/, https://github.com/shu8) @@ -175,8 +175,8 @@ } //custom events.... - sox.helpers.observe('.new_comment, .comment', () => { //custom event that triggers when a new comment appears/show more comments clicked; avoids lots of the same mutationobserver - $(document).trigger('sox-new-comment'); + sox.helpers.observe('.new_comment, .comment, .comments', (target) => { + $(document).trigger('sox-new-comment', [target]); sox.debug('sox-new-comment event triggered'); });