MSDN中英切换

switch Chinese/English language in MSDN

目前為 2019-02-27 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         MSDN中英切换
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  switch Chinese/English language in MSDN
// @author       dangoron
// @match        http*://docs.microsoft.com/en-us/*
// @match        http*://docs.microsoft.com/zh-cn/*
// @grant        none
// ==/UserScript==
var Scrollposition ;
(function() {
    'use strict';

    //获得滚动条距离顶部位置
    function getScrollTop(){
        var scrollTop=0;
        if(document.documentElement&&document.documentElement.scrollTop){
            scrollTop=document.documentElement.scrollTop;
        }else if(document.body){
            scrollTop=document.body.scrollTop;
        }
        return scrollTop;
    }
    var url = location.href;
    var a = document.createElement('span');
    function create_button(){
        var css = '    background-color:#8763c5;text-align:center;opacity:0.7;color:white;cursor:pointer;position:fixed;bottom:70%;width:45px;height:25px;right:10px;z-index:9999';
        a.style.cssText = css;
        a.innerHTML ='中/英';
        a.addEventListener('mouseover', function(){ a.style.opacity = 1;}, false);
        a.addEventListener('mouseout', function(){ a.style.opacity = 0.7; }, false);
        a.addEventListener('click', function(){
            Scrollposition = getScrollTop();
            url += "?px="+ Scrollposition;
            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();
})();
var lastIndex = window.location.href.lastIndexOf("?");
var px = window.location.href.substring(lastIndex+4,window.location.href.lenght);
window.scrollTo(0,px);