From 6ed3b1cd2556abf0f8b65ba992d0272fda6a991d Mon Sep 17 00:00:00 2001 From: Chev Date: Thu, 20 Jul 2023 14:16:05 -0700 Subject: [PATCH] UserScript redirects: Use simpler domain replacement location.hostname is a lot easier to use than replacing the domain in location.href --- scripts/redirect-reddit-new-to-old.js | 4 ++-- scripts/redirect-twitter-nitter.user.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/redirect-reddit-new-to-old.js b/scripts/redirect-reddit-new-to-old.js index a9f51ed..0ba6d02 100644 --- a/scripts/redirect-reddit-new-to-old.js +++ b/scripts/redirect-reddit-new-to-old.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Redirect: New Reddit to Old Reddit // @author Chev (https://github.com/chev2) -// @version 1.0.0 +// @version 1.0.1 // @description Redirects from new Reddit to old Reddit. // @namespace github.com/chev2 // @license Apache-2.0 @@ -21,5 +21,5 @@ (function() { 'use strict'; - location.replace(location.href.replace("www.reddit.com/", "old.reddit.com/")); + location.hostname = "old.reddit.com"; })(); diff --git a/scripts/redirect-twitter-nitter.user.js b/scripts/redirect-twitter-nitter.user.js index 41a9fe8..f55dc84 100644 --- a/scripts/redirect-twitter-nitter.user.js +++ b/scripts/redirect-twitter-nitter.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Redirect: Twitter to Nitter // @author Chev (https://github.com/chev2) -// @version 1.0.2 +// @version 1.0.3 // @description Redirects from Twitter to Nitter, a Twitter alternative front-end. // @namespace github.com/chev2 // @license Apache-2.0 @@ -23,5 +23,5 @@ // Put your instance domain here const INSTANCE_DOMAIN = "nitter.nl" - location.replace(location.href.replace("twitter.com/", `${INSTANCE_DOMAIN}/`)); + location.hostname = INSTANCE_DOMAIN; })();