MicrosoftDocsSwitchingLanguage

switch Chinese/English language in Microsoft docs websites.

目前为 2020-05-08 提交的版本。查看 最新版本

// ==UserScript==
// @name                MicrosoftDocsSwitchingLanguage
// @name:zh-CN          微软文档中英切换
// @name:zh-TW          微軟文檔中英切換
// @description         switch Chinese/English language in Microsoft docs websites.
// @description:zh-CN   在微软文档中切换中文 / 英文
// @description:zh-TW   在微軟文檔中切換中文 / 英文
// @author              dangoron
// @contributor         ladit
// @version             1.2.1
// @namespace           https://gf.qytechs.cn/zh-CN/scripts/33209
// @homepageURL         https://github.com/ladit/Userscripts
// @supportURL          https://github.com/ladit/Userscripts
// @grant               none

// @match               http*://msdn.microsoft.com/en-us/*
// @match               http*://msdn.microsoft.com/zh-cn/*
// @match               http*://docs.microsoft.com/en-us/*
// @match               http*://docs.microsoft.com/zh-cn/*
// ==/UserScript==

var switcher = document.createElement('li');
switcher.innerHTML = '<button type="button" class="button is-text has-inner-focus is-small is-icon-only-touch" title="Switch between English and Chinese" aria-pressed="false"><span class="is-visually-hidden-touch is-hidden-portrait">中文 / English</span></button>';
var actionList = document.querySelector('.action-list');
actionList.insertBefore(switcher, actionList.firstElementChild);

switcher.firstElementChild.addEventListener('click', function () {
  if (document.URL.search(/\/en-us\//) != -1) {
    window.location.replace(location.href.replace(/\/en-us\//, '\/zh-cn\/'));
  }
  if (document.URL.search(/\/zh-cn\//) != -1) {
    window.location.replace(location.href.replace(/\/zh-cn\//, '\/en-us\/'));
  }
}, false);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址