微軟文檔中英切換

在微軟文檔中切換中文 / 英文

目前為 2017-12-24 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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.1.2
// @namespace           https://greasyfork.org/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('span');
switcher.style.cssText = 'opacity: 0.5; color: black; cursor: pointer;position: fixed;bottom: 80%;left: 24%;z-index: 9999;';
switcher.innerHTML = '中文 / English 切换';

switcher.addEventListener('mouseover', function () {
  switcher.style.opacity = 1;
}, false);
switcher.addEventListener('mouseout', function () {
  switcher.style.opacity = 0.3;
}, false);

switcher.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);

document.body.appendChild(switcher);