TRPG苹果园旧页面重定向

将过时的登录画面与服务器网址重导向为新的页面

// ==UserScript==
// @name         TRPG蘋果園舊頁面重新導向
// @name:zh-CN   TRPG苹果园旧页面重定向
// @namespace    http://tampermonkey.net/
// @description  將過時的登入畫面與伺服器網址重導向為新的頁面
// @description:zh-CN  将过时的登录画面与服务器网址重导向为新的页面
// @version      1.0.1
// @author       Max
// @icon         https://www.goddessfantasy.net/favicon.gif
// @match        https://goddessfantasy.net/bbs/index.php
// @match        http://45.79.87.129/*
// @license      MPL2.0
// @grant        none
// ==/UserScript==

class Redirector {
    constructor() {
        this.oldLogInUrl = 'https://goddessfantasy.net/bbs/index.php';
        this.newHomeUrl = 'https://www.goddessfantasy.net/bbs/index.php';
        this.oldServerUrl = 'http://45.79.87.129/';
        this.newServerUrl = 'https://www.goddessfantasy.net/';
        this.init();
    }

    init() {
        const currentUrl = window.location.href;

        if (currentUrl === this.oldLogInUrl) {
            window.location.replace(this.newHomeUrl);
        }else if (currentUrl.includes(this.oldServerUrl)) {
            const newUrl = currentUrl.replace(this.oldServerUrl, this.newServerUrl);
            window.location.replace(newUrl);
        }
    }
}

new Redirector();