Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Old Reddit
- // @namespace http://tampermonkey.net/
- // @version 0.3
- // @description Reddit > Old Reddit
- // @author Matt
- // @match *://*.reddit.com/*
- // @icon https://www.google.com/s2/favicons?domain=reddit.com
- // @grant none
- // @run-at document-start
- // @license GNU GPLv2
- // ==/UserScript==
- var oldHref = document.location.href;
- if (window.location.href.indexOf('www.reddit.com') > -1) {
- window.location.replace(window.location.toString().replace('www.', 'new.'));
- }
- window.onload = function() {
- var bodyList = document.querySelector("body")
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- if (oldHref != document.location.href) {
- oldHref = document.location.href;
- console.log('location changed!');
- if (window.location.href.indexOf('wwww.reddit.com') > -1) {
- window.location.replace(window.location.toString().replace('www.', 'new.'));
- }
- }
- });
- });
- var config = {
- childList: true,
- subtree: true
- };
- observer.observe(bodyList, config);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement