Greasy Fork

Greasy Fork is available in English.

MDN 首选中文

在 developer.mozilla.org 阅读文档时,自动首选中文版本,避免手动切换。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name                MDN 首选中文
// @description         在 developer.mozilla.org 阅读文档时,自动首选中文版本,避免手动切换。

// @author              Moshel
// @namespace           https://hzy.pw
// @homepageURL         https://hzy.pw/
// @supportURL          https://github.com/h2y/link-fix
// @icon                https://blog.mozilla.com.tw/wp-content/uploads/mdn_logo_only_color.png
// @license             GPL-3.0

// @include             https://developer.mozilla.org/en-US/*
// @grant               none
// @run-at              document-start

// @version             1.0.2
// @modified            05/03/2017
// ==/UserScript==



!function() {


const allowLang = 'zh-CN',
      nowLang   = 'en-US';


//check conditions
if(document.referrer) {
    let splitRet = location.pathname.split(nowLang+'/', 2);
    if(splitRet.length!==2)
        return; // unknown location 
    const nowPath = splitRet[1];

    let regRet = document.referrer.match(/mozilla\.org\/(.+?)\/(.*)$/);
    if(regRet.length==3) {
        let lastLang = regRet[1],
            lastPath = regRet[2];

        if(lastPath==nowPath)
            return; // user choose the English version manually
    }
}


location.pathname = location.pathname.replace(nowLang, allowLang);


}();