Skip to content

Instantly share code, notes, and snippets.

@mmodrow
Last active August 4, 2020 13:25
Show Gist options
  • Save mmodrow/53689df49c263540e0f6eae45f133cde to your computer and use it in GitHub Desktop.
Save mmodrow/53689df49c263540e0f6eae45f133cde to your computer and use it in GitHub Desktop.
MSDocs redirect to english via tampermonkey
// ==UserScript==
// @name MSDocs redirect to english
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author mmodrow <marc@marcamodrow.de>
// @match https://docs.microsoft.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
if ("docs.microsoft.com" === window.location.host && window.location.pathname.toLowerCase().indexOf("/en-us/") === -1){
var redirectIndended = confirm("Redirect to english version?");
if (redirectIndended){
var regex = new RegExp("(^\/)[a-zA-Z]{2}-[a-zA-Z]{2}(.*$)");
var path = window.location.pathname.replace(regex, "$1en-us$2");
window.location = location.protocol + "//" + window.location.host + path;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment