Display MSDN content in English

Redirects regional MSDN websites to the en-US original site to prevent annoying translation elements to appear. They also have more current (fixed) content there.

  1. // Copyright (c) 2015, Yves Goergen, http://unclassified.software/source/msdn-english
  2. //
  3. // Copying and distribution of this file, with or without modification, are permitted provided the
  4. // copyright notice and this notice are preserved. This file is offered as-is, without any warranty.
  5.  
  6. // Encoding: UTF-8 without BOM (auto-detect: °°°°°)
  7.  
  8. // ==UserScript==
  9. // @namespace http://unclassified.software/
  10. // @name Display MSDN content in English
  11. // @name:de MSDN-Inhalte auf englisch anzeigen
  12. // @description Redirects regional MSDN websites to the en-US original site to prevent annoying translation elements to appear. They also have more current (fixed) content there.
  13. // @description:de Leitet regionale MSDN-Websites auf das englische Original (en-US) um, um nervende Übersetzungselemente auszublenden. Dort gibt es auch neuere (korrigierte) Inhalte.
  14. // @version 2015.2.1
  15. // @include http://msdn.microsoft.com/*
  16. // @include https://msdn.microsoft.com/*
  17. // @run-at document-start
  18. // ==/UserScript==
  19.  
  20. (function() {
  21.  
  22. // Gets the value of a single search param.
  23. // Source: https://developer.mozilla.org/en-US/docs/Web/API/URLUtils.search
  24. function getURLParam(oTarget, sVar)
  25. {
  26. return decodeURI(oTarget.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURI(sVar).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
  27. }
  28.  
  29. // Online help started from Visual Studio (2010-2013 at least)
  30. if (location.pathname.match(/\/query\/dev[0-9]{1,2}\.query/))
  31. {
  32. var locale = getURLParam(location, "l");
  33. if (locale && !locale.match(/EN-US/i))
  34. {
  35. var newUrl = location.href.replace("l=" + locale, "l=EN-US");
  36. location.replace(newUrl);
  37. return;
  38. }
  39. }
  40.  
  41. // Regular library page as seen from web search
  42. var matches = location.pathname.match(/^\/([a-z]{2}-[a-z]{2})\/library\//i);
  43. if (matches)
  44. {
  45. var locale = matches[1];
  46. if (locale && !locale.match(/en-us/i))
  47. {
  48. var newUrl = location.href.replace("/" + locale + "/", "/en-us/");
  49. location.replace(newUrl);
  50. return;
  51. }
  52. }
  53.  
  54. })()