Skip to content

Instantly share code, notes, and snippets.

@hackgrid
Forked from timvisee/SUBREDDIT_LIST.md
Created August 8, 2024 12:30
Show Gist options
  • Save hackgrid/a956fd663e2e33834f80c86ffd5b52cc to your computer and use it in GitHub Desktop.
Save hackgrid/a956fd663e2e33834f80c86ffd5b52cc to your computer and use it in GitHub Desktop.
Get a list of subreddits you're subscribed to on reddit. https://timvisee.com/blog/list-export-your-subreddits/

As posted on: https://timvisee.com/blog/list-export-your-subreddits/

Get a list of your subreddits

To obtain a list of your subreddits, do the following:

  • First make sure you're logged in on reddit, on a desktop browser.

  • Then visit reddit.com/subreddits.

  • Then put the following snippet in your browsers address bar, and press Enter.
    Make sure javascript: is included at the beginning, your browser might remove it while copy-pasting for security reasons:

    javascript:$('body').replaceWith('<body>'+$('.subscription-box').find('li').find('a.title').map((_, d) => $(d).text()).get().join("<br>")+'</body>');javascript.void()
  • The reddit page is replaced with a list of all the subreddits you're subscribed to.

For nerds

Here is the expanded snippet:

// Build a list of subreddits with break lines between them
var subs = $('.subscription-box')
    .find('li')
    .find('a.title')
    .map((_, d) => $(d).text())
    .get()
    .join("<br>"));

// Replace the page with a list of subreddits
$('body').replaceWith('<body>' + subs +'</body>');

javascript.void()

It finds all items from the subreddit list in the sidebar on the page, and builds an array of subreddit names from it. The array is concatinated with breaklines. The page is then replaced with this list.

@hackgrid
Copy link
Author

hackgrid commented Aug 8, 2024

You guys don't give the correct URL for followed user accounts!

Go to https://old.reddit.com/subreddits/mine
Open Web developers tools / javascript console
Execute following code:

a) select ALL subreddits

javascript:$('body').replaceWith(''+$('.subscription-box').find('li').find('a.title').map((_, d) => $(d).attr('href').replace('old.','')).get().join("
")+'');javascript.void()

b) select ONLY NSFW subreddits

javascript:$('body').replaceWith(''+$('.subscription-box').find('li').has('span.sr-type-icon-nsfw').find('a.title').map((_, d) => $(d).attr('href').replace('old.','')).get().join("
")+'');javascript.void()

c) select WITHOUT NSFW subreddits

javascript:$('body').replaceWith(''+$('.subscription-box').find('li').not(':has(span.sr-type-icon-nsfw)').find('a.title').map((_, d) => $(d).attr('href').replace('old.','')).get().join("
")+'');javascript.void()

If you want the old.reddit-Links, you can remove the .replace('old.','') parts.

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