UserScript redirects: Use simpler domain replacement

location.hostname is a lot easier to use than replacing the domain in location.href
This commit is contained in:
Chev 2023-07-20 14:16:05 -07:00
parent 456bc8b095
commit 6ed3b1cd25
Signed by: chev2
GPG key ID: BE0CFBD5DCBB2511
2 changed files with 4 additions and 4 deletions

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name Redirect: New Reddit to Old Reddit
// @author Chev <riskyrains@proton.me> (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";
})();

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name Redirect: Twitter to Nitter
// @author Chev <riskyrains@proton.me> (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;
})();