洛谷国内国际站自动切换

// ==UserScript==
// @name         洛谷国内国际站自动切换
// @namespace    http://tampermonkey.net/
// @version      1.4-dev
// @description  无
// @author       928418
// @match        */*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=luogu.com.cn
// @grant        none
// @license      GPL
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    var url = window.location.href;
    var path = window.location.pathname;
    var host = window.location.host;
    if (host == "www.luogu.com.cn")
    {
        //国内站,看path中是否含有paste,article或user
        //部分老的discuss必须去国际站,也加上
        //                                                                                                              这里特判消息中心
        if (path.substr(1, 5) == "paste" || path.substr(1, 7) == "article" || (path.substr(1, 4) == "user" && path.substr(1, 17) != "user/notification") || path.substr(1, 7) == "discuss")
            window.location.host = "www.luogu.com";
    }
    else if (host == "www.luogu.com")
    {
        //相反,没有就转国内,防止503
        if (path.substr(1, 5) != "paste" && path.substr(1, 7) != "article" && path.substr(1, 4) != "user" && path.substr(1, 7) != "discuss")
            window.location.host = "www.luogu.com.cn";
    }
})();