Last active
August 9, 2024 13:29
-
-
Save mmodrow/53689df49c263540e0f6eae45f133cde to your computer and use it in GitHub Desktop.
MSDocs redirect to english via tampermonkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name MSDocs redirect to english | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author mmodrow <[email protected]> | |
// @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