Microsoft Learn Language Quick Jump

Microsoft Learn Language Quick Jump Between Simple Chinese and American English

当前为 2023-04-06 提交的版本,查看 最新版本

// ==UserScript==
// @name         Microsoft Learn Language Quick Jump
// @namespace   learn.microsoft.Language.Quick.Jump
// @version      0.1
// @description  Microsoft Learn Language Quick Jump Between Simple Chinese and American English
// @author       Wanglong
// @match        learn.microsoft.com/*
// @grant        none
// @license BSD
// ==/UserScript==

(function () {
    'use strict';
    var pagePathName = window.location.pathname;
    var newLanguage = "";
    const regexCN = /^\/zh-cn/;
    const regexUS = /^\/en-us/;
    var displayText = "";
    if (pagePathName.match(regexUS) != null) {
        newLanguage = "/zh-cn";
        displayText = "GoToCN";
        pagePathName = pagePathName.replace(regexUS, newLanguage);
    } else if (pagePathName.match(regexCN) != null) {
        newLanguage = "/en-us";
        displayText = "跳转到英文";
        pagePathName = pagePathName.replace(regexCN, newLanguage);
    } else { return; }
    var bodyElement = document.body;
    var buttonDiv = document.createElement("div");
    var origin = window.location.origin;
    var str = "<div style=\"position:fixed; right:30px; bottom:30px;\"><a data-test-id=\"navbar-primary-cta\" class=\"button button-sm button-primary button-filled\" href=\"" +
        origin + pagePathName +
        "\">" + displayText + "</a></div>";
    buttonDiv.innerHTML = str;
    bodyElement.appendChild(buttonDiv);
})();

QingJ © 2025

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