Advertisement
Guest User

old reddit redirect

a guest
Jul 23rd, 2023
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Good o'l Reddit
  3. // @description Makes sure you're using Good o'l Reddit. License WTFPLV2
  4. // @version 1.0
  5. // @match *://*.reddit.com/*
  6. // @exclude *://*.reddit.com/poll/*
  7. // @exclude *://*.reddit.com/gallery/*
  8. // @exclude *://*.reddit.com/topics/*
  9. // @exclude *://*.reddit.com/t/*
  10. // @exclude https://www.reddit.com/settings/data-request
  11. // @exclude *://*.old.reddit.com/*
  12. // @run-at document-start
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. function redirectToOldReddit() {
  17. window.location.replace(
  18. "https://old.reddit.com" +
  19. window.location.pathname +
  20. window.location.search +
  21. window.location.hash
  22. );
  23. }
  24.  
  25. function redirectToNewReddit() {
  26. const host = window.location.host;
  27. const newRedditRegex = /^(new\.reddit\.com)$/i;
  28. if (newRedditRegex.test(host)) {
  29. redirectToOldReddit();
  30. }
  31. }
  32.  
  33. function redirectToReddit() {
  34. const host = window.location.host;
  35. const redditRegex = /^(reddit\.com)$/i;
  36. if (redditRegex.test(host)) {
  37. redirectToOldReddit();
  38. }
  39. }
  40.  
  41. function redirectToTwoLetterDomain() {
  42. const host = window.location.host;
  43. const twoLetterDomainRegex = /^[a-z]{2}\.reddit\.com$/i;
  44. if (twoLetterDomainRegex.test(host)) {
  45. redirectToOldReddit();
  46. }
  47. }
  48.  
  49. function redirectToOldRedditIfNotOnOldOrRedditOrTwoLetterDomain() {
  50. const host = window.location.host;
  51. if (
  52. host !== "old.reddit.com" &&
  53. !/^(reddit\.com|new\.reddit\.com|[a-z]{2}\.reddit\.com)$/i.test(host)
  54. ) {
  55.  
  56. redirectToOldReddit();
  57. }
  58. }
  59.  
  60.  
  61. redirectToNewReddit();
  62. redirectToReddit();
  63. redirectToTwoLetterDomain();
  64. redirectToOldRedditIfNotOnOldOrRedditOrTwoLetterDomain();
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement