Skip to content

Instantly share code, notes, and snippets.

@Rainyan
Last active May 3, 2024 10:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Rainyan/fbb1ff337eac3e6c604d9a6eee7badda to your computer and use it in GitHub Desktop.
Save Rainyan/fbb1ff337eac3e6c604d9a6eee7badda to your computer and use it in GitHub Desktop.
UserScript to always redirect to old reddit style, without relying on cookies. Another userscript recommended for fixing old.reddit URLs: https://gist.github.com/Rainyan/0fdf3d449404fb786ea1a29589608ce5/
// ==UserScript==
// @name Always use old Reddit style
// @description Convert www.reddit urls into old.reddit urls on page load start. This can be useful if you often clear your cookies but want this setting to persist.
// @version 1.5.2
// @namespace redditAlwaysOldStyle
// @updateURL https://gist.githubusercontent.com/Rainyan/fbb1ff337eac3e6c604d9a6eee7badda/raw/
// @include https://www.reddit.com/*
// @exclude https://www.reddit.com/gallery/*
// @exclude https://www.reddit.com/login/*
// @exclude https://www.reddit.com/media?*
// @exclude https://www.reddit.com/poll/*
// @run-at document-start
// ==/UserScript==
// Another userscript recommended for fixing old.reddit URLs: https://gist.github.com/Rainyan/0fdf3d449404fb786ea1a29589608ce5/
if (!String.prototype.replaceFirst) {
String.prototype.replaceFirst = function(search, replace) {
return this.replace(new RegExp(search + '+?'), replace);
};
}
var url = document.location.href;
// Because we're doing a non-greedy search (only replace first), and the domain
// is guaranteed to start with www.reddit.com by the UserScript @include,
// we can safely assume this is the first occurrence of these phrases in the url.
url = url.replaceFirst('www', 'old');
window.location.replace(url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment