Reddit - Auto Expand Hidden Comments in 2025

This userscript was created by an AI. It will most likely never be updated, so consider it 'as is.'

  1. // ==UserScript==
  2. // @name Reddit - Auto Expand Hidden Comments in 2025
  3. // @version 0.01.04
  4. // @description This userscript was created by an AI. It will most likely never be updated, so consider it 'as is.'
  5. // @namespace makewebsitesbetter
  6. // @icon https://i.postimg.cc/3NMLffrh/greenbox.png
  7. // @include *://www.reddit.com/*
  8. // @run-at document-start
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function expandComments() {
  17. const comments = document.querySelectorAll('shreddit-comment[collapsed]');
  18. comments.forEach(comment => {
  19. // Set action row height to 32px during loading
  20. const actionRow = comment.querySelector('shreddit-comment-action-row');
  21. if (actionRow) {
  22. actionRow.style.maxHeight = '32px';
  23. actionRow.style.height = '32px';
  24. }
  25. // Remove collapsed attribute to expand the comment
  26. comment.removeAttribute('collapsed');
  27. });
  28. }
  29.  
  30. // Observe DOM changes to capture new comments dynamically
  31. const observer = new MutationObserver((mutations) => {
  32. mutations.forEach(mutation => {
  33. if (mutation.addedNodes.length > 0) {
  34. expandComments();
  35. }
  36. });
  37. });
  38.  
  39. // Start observing the document body
  40. observer.observe(document.body, { childList: true, subtree: true });
  41.  
  42. // Initial run to expand comments on page load
  43. window.addEventListener('load', () => {
  44. setTimeout(expandComments, 5000); // 5-second delay to allow all elements to load
  45. });
  46. })();