MDN 重定向到中文

重定向 MDN 文档到中文

// ==UserScript==
// @name        MDN 重定向到中文
// @description 重定向 MDN 文档到中文
// @namespace   http://huching.net
// @include     https://developer.mozilla.org/
// @match       *://developer.mozilla.org/*
// @match       https://developer.mozilla.org/*
// @version     1.007
// @grant       none
// @license     MIT License
// @supportURL  http://huching.net
// @icon        data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2Ni4xNDU4MzIgNjYuMTQ1ODM1IiBoZWlnaHQ9IjI1MCIgd2lkdGg9IjI1MCI+PGc+PHBhdGggZD0iTTMzLjE0OCA2Mi4zNjlsMTYuNTAzLTYuMzU5IDE2LjUwMyA2LjM1OXYtNTEuNzc5bC0xNi41MDMtNi41MXYtLjE1MS4xNTFsLS4xNTEtLjE1MXYuMTUxbC0xNi4zNTEgNi41MS0xNi42NTQtNi41MXYtLjMwMi4xNTEuMTUxbC0xNi41MDMgNi41MXY1MS43NzlsMTYuNTAzLTYuMzU5IDE2LjY1NCA2LjM1OXoiIGZpbGw9IiMyNTkzZDEiLz48cGF0aCBkPSJNNTYuNzY2IDM0LjIwOWMtLjYwNi0xLjY2NS0uNDU0LTQuNjkzLS43NTctNS4xNDgtMS45NjgtMi41NzQtOC45MzMtMy4xNzktMTIuMTEyLTYuNjYyLjYwNi0xLjY2NS0uNjA2LTMuMTc5LTEuNjY1LTQuMjM5LTEuNjY1LTEuMjExLTQuMDg4LS43NTctNi4wNTYtLjE1Mi0yLjEyLS40NTQtNC4wODgtMS4yMTEtNi4wNTYtMS44MTctNC41NDItLjQ1NC05LjA4NCAyLjcyNS05LjA4NCAyLjcyNS0zLjMzMSAyLjEyLTguMzI3IDYuMzU5LTEwLjkwMSA4LjkzMy42MDYgMCAxLjIxMS0uNDU0IDEuOTY4LS40NTRsNC42OTMtMS4yMTFjLTEuOTY4IDEuNjY1LTYuMDU2IDQuMzkxLTcuMjY3IDYuNjYyIDEu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NTYuMDF2LTUyLjA4MmwtMTYuNTAzIDYuNjYydjUxLjc3OXoiIGZpbGwtb3BhY2l0eT0iLjA1OSIvPjxwYXRoIGQ9Ik00OS42NTEgNTYuMDF2LTUyLjA4MmwtMTYuNTAzIDYuNjYydjUxLjc3OXoiIGZpbGwtb3BhY2l0eT0iLjA1MSIvPjwvZz48L3N2Zz4=
// ==/UserScript==
'esversion: 6';

let winLoc = window.location.href;
if (winLoc.match('\/en-US\/|\/en\/') !== null) {
  window.location.href = winLoc.replace(/\/en-US\/|\/en\//i, '\/zh-CN\/');
}
let mdnLink = document.links;
for (let i = 0; i < mdnLink.length; i++) {
  if (mdnLink[i].href.match('\/en-US\/|\/en\/') !== null) {
    mdnLink[i].href = mdnLink[i].href.replace(/\/en-US\/|\/en\//i, '\/zh-CN\/');
  }
}