Reddit Old Redirect 🔙

redirect to old reddit

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Reddit Old Redirect 🔙
// @namespace    https://www.reddit.com
// @version      1.9
// @description  redirect to old reddit
// @author       Agreasyforkuser
// @match        https://*.reddit.com/*
// @exclude      https://*.reddit.com/poll/*
// @exclude      https://*.reddit.com/gallery/*
// @exclude      https://chat.reddit.com/*
// @exclude      https://www.reddit.com/appeal*
// @exclude      https://www.reddit.com/notifications*
// @exclude      https://embed.reddit.com/*
// @exclude      https://www.reddit.com/mail/*
// @exclude      https://sh.reddit.com/report-flow*
// @icon         https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png
// @license      MIT
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // do nothing if we are already on old.reddit.com
    if (window.location.hostname === 'old.reddit.com') return;

    // feature to display raw media embeddings, avoid new reddit media viewer
    // redirect "https://preview.redd.it/image.jpeg" links to blank page with raw image
    const href = window.location.href;
    const params = new URLSearchParams(window.location.search);
    const imgParam = params.get('url');
    if (imgParam && /\.(?:png|jpe?g|gif|webp|bmp)(?:\?.*)?$/i.test(imgParam)) {
        document.open();
        document.write(`
       <!DOCTYPE html>
        <html>
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
            <title>Reddit Media</title>
            <style>
                html, body {
                    margin: 0;
                    padding: 0;
                    width: 100%;
                    height: 100%;
                    background: black;
                    overflow: hidden; /* Prevent scrolling */
                }
                body {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                }
                img {
                    max-width: 100vw;
                    max-height: 100vh;
                    width: auto;
                    height: auto;
                    object-fit: contain;
                }
            </style>
        </head>
        <body>
            <img src="${imgParam}" alt="image">
        </body>
        </html>`);
        document.close();
        return;
    }

    // general Redirect to old.reddit.com
    if ( window.location.host != "old.reddit.com" ) {
        var oldReddit = window.location.protocol + "//" + "old.reddit.com" + window.location.pathname + window.location.search + window.location.hash;
        window.location.replace (oldReddit);
    }
})();