微软文档中英切换

微软文档中英切换;switch Chinese/English language in Microsoft Docs.

Stan na 15-09-2017. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         微软文档中英切换
// @namespace    https://greasyfork.org/zh-CN/scripts/33209
// @version      0.2
// @description:zh-CN  在微软文档里中英切换
// @description:en-US  switch Chinese/English language in Microsoft Docs.
// @author       dangoron
// @contributor  ladit
// @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/*
// @grant        none
// @description 微软文档中英切换;switch Chinese/English language in Microsoft Docs.
// ==/UserScript==

(function () {
  'use strict';

  var url = location.href;
  var a = document.createElement('span');

  function create_button() {
    var css = 'opacity: 0.5;color: black;cursor: pointer;position: fixed;bottom: 80%;left: 24%;z-index: 9999;';
    a.style.cssText = css;
    a.innerHTML = '中文 / English 切换';
    a.addEventListener('mouseover', function () {
      a.style.opacity = 1;
    }, false);
    a.addEventListener('mouseout', function () {
      a.style.opacity = 0.3;
    }, false);
    a.addEventListener('click', function () {
      if (url.search(/\/en-us\//) != -1) {
        window.location.replace(url.replace(/\/en-us\//, '\/zh-cn\/'));
      }
      if (url.search(/\/zh-cn\//) != -1) {
        window.location.replace(url.replace(/\/zh-cn\//, '\/en-us\/'));
      }
    }, false);
    document.body.appendChild(a);
  }
  create_button();
})();