Advertisement
Guest User

Old Reddit

a guest
Feb 2nd, 2024
740
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | Source Code | 0 0
  1. // ==UserScript==
  2. // @name Old Reddit
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Reddit > Old Reddit
  6. // @author Matt
  7. // @match *://*.reddit.com/*
  8. // @icon https://www.google.com/s2/favicons?domain=reddit.com
  9. // @grant none
  10. // @run-at document-start
  11. // @license GNU GPLv2
  12. // ==/UserScript==
  13. var oldHref = document.location.href;
  14. if (window.location.href.indexOf('www.reddit.com') > -1) {
  15. window.location.replace(window.location.toString().replace('www.', 'new.'));
  16. }
  17. window.onload = function() {
  18. var bodyList = document.querySelector("body")
  19. var observer = new MutationObserver(function(mutations) {
  20. mutations.forEach(function(mutation) {
  21. if (oldHref != document.location.href) {
  22. oldHref = document.location.href;
  23. console.log('location changed!');
  24. if (window.location.href.indexOf('wwww.reddit.com') > -1) {
  25. window.location.replace(window.location.toString().replace('www.', 'new.'));
  26. }
  27. }
  28. });
  29. });
  30. var config = {
  31. childList: true,
  32. subtree: true
  33. };
  34. observer.observe(bodyList, config);
  35. };
Tags: termermonkey
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement