Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sidneys/759bdb70442597638d63c4ed170020c9 to your computer and use it in GitHub Desktop.
Save sidneys/759bdb70442597638d63c4ed170020c9 to your computer and use it in GitHub Desktop.
Userscript | Reddit | Expand All Comments
// ==UserScript==
// @name Reddit | Expand All Comments
// @namespace de.sidneys.userscripts
// @homepage https://gist.githubusercontent.com/sidneys/759bdb70442597638d63c4ed170020c9/raw/
// @version 1.0.0
// @description Automatically expands all comment replies within Reddit threads
// @author sidneys
// @icon https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-180x180.png
// @include http*://www.reddit.com/*/comments/*
// @require https://greasyfork.org/scripts/38888-greasemonkey-color-log/code/Greasemonkey%20%7C%20Color%20Log.js
// @require https://greasyfork.org/scripts/38889-greasemonkey-waitforkeyelements-2018/code/Greasemonkey%20%7C%20waitForKeyElements%202018.js
// @run-at document-end
// ==/UserScript==
/**
* @default
* @constant
*/
DEBUG = false
/**
* Expand all comments recursively
*/
let expandComments = () => {
console.debug('expandComments');
// Search for "X more replies" element
waitForKeyElements('div[id^="moreComments"] p', (element) => {
if (!element.innerText.match(/^(\d+) more/)) { return }
element.click()
console.debug('Comment thread expanded.');
});
}
/**
* Init
*/
let init = () => {
console.info('init');
expandComments()
};
/**
* @listens window:Event#load
*/
window.addEventListener('load', () => {
console.debug('window#load');
init();
});
@realAzazello
Copy link

Hello. I was hoping this would be the solution to years'-long struggle but it's not working for my setup:

Firefox 115.6.0esr
Tampermoneky 5.11

A few items:

  • Does this work if not logged-in? Can you make it so?
  • I added http*://old.reddit.com/*/comments/* to user Includes, but it still doesn't work.
  • I added both http*://old.reddit.com/*/comments/* and http*://www.reddit.com/*/comments/* to User Matches but still no joy.
  • Might not be needed but it is customary to include a 'grant' statement. I added // @grant none.

I do have several other userscripts installed specifically for Reddit (and whole bunch for other stuff); let me know if there are any conflicts I should look out for.

@gaveitatry2
Copy link

Doesn't work for me.

Google Chrome v132.0.6834.111 (Official Build) (64-bit)
Violentmonkey 2.29.0

@gaveitatry2
Copy link

gaveitatry2 commented Jan 26, 2025

On Jan 26, 2025, I used an AI to create this userscript and it seems to be working.

https://greasyfork.org/en/scripts/524909-reddit-auto-expand-hidden-comments-by-ai

@realAzazello - I don't know if my userscript will work for you, but you could give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment