Last active
August 29, 2024 09:33
-
-
Save sidneys/759bdb70442597638d63c4ed170020c9 to your computer and use it in GitHub Desktop.
Userscript | Reddit | Expand All Comments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment