Skip to content

Instantly share code, notes, and snippets.

@juanigaray
Last active June 19, 2024 16:21
Show Gist options
  • Save juanigaray/0b5194c99c47d2cce795e3c6da8d6c71 to your computer and use it in GitHub Desktop.
Save juanigaray/0b5194c99c47d2cce795e3c6da8d6c71 to your computer and use it in GitHub Desktop.
Good ol' Reddit v2
// ==UserScript==
// @name Good o'l Reddit
// @description Makes sure you're using Good o'l Reddit. (C) TheNH813 2018, additions by Chana G. License WTFPLV2
// @version 1.0
// @match *://*.reddit.com/*
// @run-at document-start
// @grant none
// ==/UserScript==
// old.reddit.com doesn't work on media
const pageIsMedia = window.location.pathname === "/media";
if ( window.location.host !== "old.reddit.com" && !pageIsMedia) {
var oldReddit = window.location.protocol + "//" + "old.reddit.com" + window.location.pathname + window.location.search + window.location.hash;
/* Automatically translated posts have URLs that contain something like an `/es` at the end which makes old reddit 404.
* e.g. https://old.reddit.com/r/Bass/comments/143cqt6/amplificador_de_bajo_para_tocar/es/
* removing the latter part fixes it.
*/
if(oldReddit.includes("comments/")){
const [formerHalfOfUrl, latterHalfOfUrl] = oldReddit.split("comments/");
const postId = latterHalfOfUrl.split("/")[0]; // we only need the post ID. The post slug is automatically replaced anyways
oldReddit = formerHalfOfUrl + "/comments/" + postId;
}
window.location.replace(oldReddit);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment