TamperMonkey Reddit > Alternative Reddit Redirect

I’ve been self-hosting a Reddit alternative (LibReddit) for a while now, and could not imagine a world where I go back to their vanilla front-end again (ew). Tools like LibRedirect maintain a list of self-hosted alternatives automatically. They also round robin random public LibReddit instances by default. I highly recommend adding them to your extension library.

However, I wanted a bit more control over my redirects. The following TamperMonkey script will allow you to build as many custom redirects as you wish.

// ==UserScript==
// @name         Reddit to SafeReddit Redirect
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Redirects all Reddit links to alternatives
// @author       You
// @match        *://*.reddit.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    let currentUrl = window.location.href;

    // Redirect www, old, and pay prefixes to alternative reddit
    if (currentUrl.includes('reddit.com')) {
        currentUrl = currentUrl.replace(/(www\.|pay\.|old\.)?reddit\.com/, 'safereddit.com');
        window.location.replace(currentUrl);
    }
})();
Previous: Argylle Next: Generation Kill