Reddit Old

Redirects to old.reddit.com if the user chooses to use it on Reddit's new design.

  1. // ==UserScript==
  2. // @name Reddit Old
  3. // @namespace https://tampermonkey.net
  4. // @version 1.21
  5. // @description Redirects to old.reddit.com if the user chooses to use it on Reddit's new design.
  6. // @author Ondry
  7. // @match https://www.reddit.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function createPrompt() {
  16. const promptDiv = document.createElement('div');
  17. promptDiv.setAttribute('id', 'old-reddit-prompt');
  18. promptDiv.setAttribute('class', 'old-reddit-prompt');
  19. promptDiv.setAttribute('style', 'position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: white; padding: 20px; border: 2px solid black; z-index: 9999; color: black; text-align: center;');
  20. const promptText = document.createElement('p');
  21. promptText.textContent = 'Do you want to use old Reddit?';
  22. promptDiv.appendChild(promptText);
  23. const buttonContainer = document.createElement('div');
  24. buttonContainer.setAttribute('style', 'display: flex; justify-content: space-between; margin-top: 10px;');
  25. const yesButton = document.createElement('button');
  26. yesButton.textContent = 'Yes';
  27. yesButton.addEventListener('click', redirectToOldReddit);
  28. buttonContainer.appendChild(yesButton);
  29. const noButton = document.createElement('button');
  30. noButton.textContent = 'No';
  31. noButton.addEventListener('click', closePrompt);
  32. buttonContainer.appendChild(noButton);
  33. promptDiv.appendChild(buttonContainer);
  34. document.body.appendChild(promptDiv);
  35. }
  36.  
  37. function redirectToOldReddit() {
  38. window.location.href = 'https://old.reddit.com';
  39. }
  40.  
  41. function closePrompt() {
  42. const promptDiv = document.getElementById('old-reddit-prompt');
  43. promptDiv.parentNode.removeChild(promptDiv);
  44. }
  45.  
  46. createPrompt();
  47. })();