Wikipedia zh-tw+Desktop version Redirect

把手機版Wiki導向桌面版+把非台灣繁中的中文Wiki頁面(如港中、簡中等等)導向台灣繁中

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Wikipedia zh-tw+Desktop version Redirect
// @description 把手機版Wiki導向桌面版+把非台灣繁中的中文Wiki頁面(如港中、簡中等等)導向台灣繁中
// @icon https://wikipedia.org/favicon.ico
// @author       Kamikiri
// @namespace    [email protected]
// @match       *://*.m.wikipedia.org/*
// @match       *://*.wikipedia.org/zh-hant/*
// @match       *://*.wikipedia.org/zh-cn/*
// @match       *://*.wikipedia.org/zh-hk/*
// @match       *://*.wikipedia.org/zh-mo/*
// @match       *://*.wikipedia.org/zh-my/*
// @match       *://*.wikipedia.org/zh-sg/*
// @license     GPL
// @version     1.0
// @grant       none
// ==/UserScript==

(function() {
    'use strict';

    var url = location.href;

    // 1. 把手機版Wiki導向桌面版
    var mobileRegex = /^(https?:\/\/.*)\.m(\.wikipedia\.org\/.*)/;
    if (mobileRegex.exec(url)) {
        location.href = url.replace('.m.', '.');
        return;
    }

    // 2. 把非台灣繁中的中文Wiki頁面導向台灣繁中(如港中、簡中等等)
    var langRegex = /^(https?:\/\/.*)(\.wikipedia\.org\/zh-)(hans|hant|cn|hk|mo|my|sg).*?(\/.*)/;
if (!location.href.includes("zh-tw")) {
    location.href = location.href.replace(/(\.wikipedia\.org\/zh-)(hans|hant|cn|hk|mo|my|sg)(\/.*)/, '$1tw$3');
}
})();