diff --git a/script.js b/script.js index 3c718e5..26b631d 100644 --- a/script.js +++ b/script.js @@ -9,6 +9,8 @@ function toggleComments() { } else { label.textContent = 'Hide comments'; } + + showReadMore(); } function inject() { @@ -31,6 +33,19 @@ function addButton() { document.getElementById('toggle-comments').addEventListener('click', toggleComments); } +function showReadMore() { + showReadMore = function() {}; // Become a no-op after executing. + + const maxHeight = 65; + const commentContents = document.getElementsByClassName('comment-renderer-text-content'); + + for (var comment of commentContents) { + if (comment.scrollHeight > maxHeight) { + comment.nextElementSibling.classList.remove('hid'); + } + }; +} + (function () { document.addEventListener('DOMContentLoaded', inject); // Static navigation (i.e. initial page load) document.addEventListener('spfdone', inject); // Dynamic navigation (i.e. subsequent page loads)