切换文档语言至简体中文

支持MSDN/MDN

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         切换文档语言至简体中文
// @namespace    https://github.com/Sunhelter/LearningFile/blob/master/UserScript/Chang.en-us.to.zh-CN.js
// @version      0.8.1
// @description  支持MSDN/MDN
// @author       Sunhelter
// @license      MIT
// @date         2019-05-15
// @match        *://docs.microsoft.com/*
// @match        *://learn.microsoft.com/*
// @match        *://support.microsoft.com/*
// @match        *://azure.microsoft.com/*
// @match        *://developer.mozilla.org/*
// @exclude      *://learn.microsoft.com/en-us/answers/*
// @grant        none
// ==/UserScript==

(function () {
    var url = window.location.href;
    var cnurl = window.location.href;

    if (url.indexOf("/en-us") > -1) {
        cnurl = url.replace('/en-us', '/zh-CN');
    }
    else if (url.indexOf("/en-US") > -1) {
        cnurl = url.replace('/en-US', '/zh-CN');
    }
    else if (url.indexOf("/zh-tw") > -1) {
        cnurl = url.replace('/zh-tw', '/zh-CN');
    }
    else if (url.indexOf("/zh-TW") > -1) {
        cnurl = url.replace('/zh-TW', '/zh-CN');
    }

    if (cnurl != url) {
        window.location.href = cnurl;
    }
})();