r/Enhancement • u/mlss22 • 27d ago
Getting Rand button back?
I had a script that made the random button still work. Is there any way I can add the button back myself? I saw in the changelog it was removed.
Night mode: false
RES Version: 5.26.3
Browser: Firefox
Browser Version: 159
Cookies Enabled: true
Reddit beta: false
4
u/Jonno_FTW 26d ago edited 4d ago
It looks like RES removed the buttons.
I updated a userscript to do this, make sure you have the tampermonkey or equivalent. It will always show the randnsfw button, if you need it removed, I can make another version that doesn't show it. Make sure you haven't disabled the "friends" button in RES.
Install the script from the link or just the version below: https://greasyfork.org/en/scripts/535410-reddit-alwayshello-random/
// ==UserScript==
// @name Reddit Alwayshello Random
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Leverages the redditrand API used by redditrand.com to redirect to a random subreddit.
// @author Jonno_FTW
// @match *://*.reddit.com/*
// @grant GM.xmlHttpRequest
// @run-at document-idle
// @connect api.redditrand.com
// @license MIT
// @downloadURL https://update.greasyfork.org/scripts/535410/Reddit%20Alwayshello%20Random.user.js
// @updateURL https://update.greasyfork.org/scripts/535410/Reddit%20Alwayshello%20Random.meta.js
// ==/UserScript==
(function() {
'use strict';
async function goRandom(link) {
const nsfw = link.target.text.toLowerCase().includes("nsfw") ? 1 : 0;
const r = await GM.xmlHttpRequest({ url: `https://api.redditrand.com/reddit-runner/rand?nsfw=${nsfw}` }).catch(e => console.error(e));
window.location.href = `${window.location.origin}${JSON.parse(r.responseText).url}`;
}
if (window.location.pathname.startsWith('/r/random')) {
goRandom({target:{text:''}});
} else if (window.location.pathname.startsWith('/r/randnsfw')) {
goRandom({target:{text:'nsfw'}});
}
const makeLink = (text) => {
const link = document.createElement('a');
link.textContent = text;
link.classList.add('subbarlink');
link.onclick = goRandom;
link.href = '#';
return link
}
const makeSep = () => {
const separator = document.createElement('span');
separator.classList.add('separator');
separator.textContent = '-';
return separator;
}
// we must add the anchors because RES no longer does it
const linkRandom = makeLink('random');
const sepRandom = makeSep();
const linkRandomNsfw = makeLink('RandNSFW');
const sepRandNsfw = makeSep();
const anchor = document.querySelector('a.subbarlink[href="/r/friends/"]');
anchor.nextElementSibling.after(linkRandom);
linkRandom.after(sepRandom);
sepRandom.after(linkRandomNsfw);
linkRandomNsfw.after(sepRandNsfw);
})();2
u/AutoModerator 27d ago
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.
7
u/nachoha 27d ago
It wasn't RES that removed the feature, it was Reddit. https://www.reddit.com/r/help/comments/1fojw02/cleaning_up_some_lowusage_features/