MicrosoftDocsSwitchingLanguage

switch Chinese/English language in Microsoft docs websites.

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

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