微软文档中英切换

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

当前为 2017-09-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name 微软文档中英切换
  3. // @namespace https://greasyfork.org/zh-CN/scripts/33209
  4. // @version 0.2
  5. // @description:zh-CN 在微软文档里中英切换
  6. // @description:en-US switch Chinese/English language in Microsoft Docs.
  7. // @author dangoron
  8. // @contributor ladit
  9. // @match http*://msdn.microsoft.com/en-us/*
  10. // @match http*://msdn.microsoft.com/zh-cn/*
  11. // @match http*://docs.microsoft.com/en-us/*
  12. // @match http*://docs.microsoft.com/zh-cn/*
  13. // @grant none
  14. // @description 微软文档中英切换;switch Chinese/English language in Microsoft Docs.
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. 'use strict';
  19.  
  20. var url = location.href;
  21. var a = document.createElement('span');
  22.  
  23. function create_button() {
  24. var css = 'opacity: 0.5;color: black;cursor: pointer;position: fixed;bottom: 80%;left: 24%;z-index: 9999;';
  25. a.style.cssText = css;
  26. a.innerHTML = '中文 / English 切换';
  27. a.addEventListener('mouseover', function () {
  28. a.style.opacity = 1;
  29. }, false);
  30. a.addEventListener('mouseout', function () {
  31. a.style.opacity = 0.3;
  32. }, false);
  33. a.addEventListener('click', function () {
  34. if (url.search(/\/en-us\//) != -1) {
  35. window.location.replace(url.replace(/\/en-us\//, '\/zh-cn\/'));
  36. }
  37. if (url.search(/\/zh-cn\//) != -1) {
  38. window.location.replace(url.replace(/\/zh-cn\//, '\/en-us\/'));
  39. }
  40. }, false);
  41. document.body.appendChild(a);
  42. }
  43. create_button();
  44. })();