Redirect Unity China to Unity3D

将 *.unity.cn 页面重定向到 unity3d.com

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Redirect Unity China to Unity3D
// @namespace    http://creationwong.xyz
// @version      1.1
// @description  将 *.unity.cn 页面重定向到 unity3d.com
// @author       creationwong
// @match        https://*.unity.cn/*
// @license      EPL
// ==/UserScript==

(function () {
    'use strict';

    const newUrl = 'https://unity3d.com'
        + window.location.pathname
        + window.location.search
        + window.location.hash;

    // 创建提示条
    const notice = document.createElement('div');
    notice.style.position = 'fixed';
    notice.style.top = '0';
    notice.style.left = '0';
    notice.style.width = '100%';
    notice.style.backgroundColor = '#4CAF50';
    notice.style.color = '#fff';
    notice.style.textAlign = 'center';
    notice.style.padding = '10px 0';
    notice.style.zIndex = '9999';
    notice.style.fontFamily = 'Arial, sans-serif';
    notice.style.fontSize = '16px';
    notice.textContent = '正在跳转到 unity3d.com...';

    document.body.prepend(notice);

    setTimeout(() => {
        window.location.href = newUrl;
    }, 1000);
})();