New Reddit Redirect

redirects you to new.reddit.com

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name New Reddit Redirect
// @version      0.1.0
// @description  redirects you to new.reddit.com
// @author       github.com/lasersPew
// @match *://*.reddit.com/*
// @exclude /^https?://[a-z]{2}\.reddit\.com/*
// @exclude *out.reddit.com/*
// @exclude *://*.reddit.com/gallery/*
// @exclude *://*.reddit.com/media*
// @run-at document-start
// @license     GPLv3
// @grant        none
// @namespace https://greasyfork.org/users/1267998
// ==/UserScript==

// Enforce strict mode for better code quality
(function () {
   'use strict';

    // Declare constant for current URL
    const currentUrl = window.location.href;
    
    // Declare constant for old reddit URL
    const newRedditUrl = 'https://new.reddit.com/';
    
    // Check if the current URLis not new.reddit.com
    if ((!currentUrl.includes("www.reddit.com")) && (!GM_info.isIncognito )) {
    
      // Use regex literal and constant for new URL
      const newUrl = currentUrl.replace(/^https?:\/\/(www\.)?reddit.com\//, newRedditUrl);
    
      // Redirect to new URL without history entry
      window.location.replace(newUrl);
    }
}());