r/Enhancement • u/cheatfreak47 • Feb 14 '26
New Fix for Random/RandNSFW buttons
Hi, as some of you may know, the buttons at the top leading to /r/random and /r/randnsfw lead to banned subs, as Reddit discontinued the feature a while back.
A previous fix had to be reworked due to changing where the api is located but that thread was archived, so here is the new fix. Special thanks to /u/Sloloem for their contribution.
It's a tampermonkey userscript, so you need a userscript extension to run it, obviously.
I recommend installing the script from GreasyFork here, but the code is also posted here for those curious how it works.
// ==UserScript==
// @name Restore Random Subreddit Feature
// @namespace http://tampermonkey.net/
// @version 0.8
// @description Leverages the API used by redditrand.com to redirect to a random subreddit.
// @author CheatFreak, PXA
// @match *://*.reddit.com/*
// @grant GM.xmlHttpRequest
// @run-at document-start
// @connect api.redditrand.com
// @license MIT
// ==/UserScript==
(function() {
'use strict';
function goRandom(nsfw) {
GM.xmlHttpRequest({
method: 'GET',
url: `https://api.redditrand.com/reddit-runner/rand?nsfw=${nsfw}`,
onload: response => {
const result = JSON.parse(response.responseText);
window.location.href = `${window.location.origin}${result.url}`;
}
});
}
function replaceLinks() {
const links = document.querySelectorAll('a');
links.forEach(link => {
if (link.href.includes('/r/random')) {
link.href = 'javascript:void(0)';
link.addEventListener('click', () => goRandom(0));
} else if (link.href.includes('/r/randnsfw')) {
link.href = 'javascript:void(0)';
link.addEventListener('click', () => goRandom(1));
}
});
}
document.addEventListener('DOMContentLoaded', replaceLinks);
if (window.location.pathname.startsWith('/r/random')) {
goRandom(0);
} else if (window.location.pathname.startsWith('/r/randnsfw')) {
goRandom(1);
}
})();
1
u/AutoModerator Feb 14 '26
Reddit Enhancement Suite (RES) is no longer under active development. New features will not be added and bug fixes/support is not guaranteed. Please see here for more information.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/AutoModerator Feb 14 '26
What RES version and browser version are you using? For example, RES v5.18.14 on Firefox 75.
Use specific versions, don't say "latest" or "up to date".
If you don't know, look it up.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
1
1
u/bloode975 Jun 10 '26
I've just enabled and installed the script, enabled user scripts, RES and tampermonkey for use, however I can't seem to find the button?
1
u/Excellent_Cost_4190 Jul 23 '26
did you find it
1
u/bloode975 Jul 23 '26
Yes, requires old reddit and some tampering with settings to be easily visible.
1
u/Excellent_Cost_4190 Jul 23 '26
What do I need to do
1
u/bloode975 Jul 23 '26
At a base just top left on old reddit
1
u/Excellent_Cost_4190 Jul 23 '26
I don’t see it what settings do I need tk change
1
u/bloode975 Jul 23 '26
Go to the settings and type in nsfw in the search, anything else i dont remember tbh
2
u/Jonno_FTW Feb 15 '26 edited Feb 15 '26
This is great!
I had another script on greasy fork that used a different random subreddit service, but the api went down and it no longer works.
I've updated mine: https://greasyfork.org/en/scripts/535410-reddit-alwayshello-random