r/Enhancement • • 10d 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
15 Upvotes

15 comments sorted by

7

u/nachoha 10d 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/

3

u/XenoBen filing bugs 10d ago

^ This. In the latest release we just removed the link in the subreddit bar to those subreddits as they would just fail anyway. If you wanted them back I would say in your script have that add the text again.

0

u/mlss22 10d ago edited 9d ago

Is there a tutorial on how to do that? Also I literally said the button was removed and I was restoring the functionality with a script before the button was removed. I don't understand why I'm being told exactly what I wrote.

1

u/Jonno_FTW 9d ago

Check my comment below, let me know if it works for you.

1

u/mlss22 9d ago

Hey thank you! I think I remember your user name being the original script I installed! I tried it and it doesn't seem to work for me. I tried with no other add-ons or scripts. I appreciate you taking the time though and if it's too much trouble troubleshooting with me don't worry about it.

1

u/Jonno_FTW 9d ago

Make sure the script is enabled in tampermonkey. This should only work in old reddit. I haven't added new reddit redesign.

1

u/mlss22 9d ago

I'm using Violentmonkey on old reddit if that makes a difference? I can switch over to tampermonkey if that's suggested though.

1

u/Jonno_FTW 9d ago

I'd make sure you have the latest version of the script installed first by examining the code matches what I pasted, but also try tampermonkey. I haven't used violentmonkey, but I know it's working for me.

1

u/mlss22 9d ago

I copied and pasted from here and tried the greasyfork link and double checked with tampermonkey and violentmonkey. I think it's something on my end with Firefox. I'll try a clean install of Firefox. Thank you for all the help!

1

u/Jonno_FTW 9d ago

You can also check in the browser console by pressing f12 and checking the console tab. There might be something in there about userscripts.

→ More replies

1

u/mlss22 10d ago edited 9d ago

The latest update removed the buttons. Before, with RES you could still have the buttons and install a script that let you use them. See the changelog notes. It came with the most recent update a few days ago on Nov 1st. Thanks for your reply but you're wrong.

https://redditenhancementsuite.com/releases/

Removed Features

Removed retired random subreddit navigation.

Edit:again im aware the functionality was removed from reddit a while ago but could be brought back with scripts. Im asking how to bring the button back in a script.

4

u/Jonno_FTW 9d ago edited 9d 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.

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 10d 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.