Skip to content

Instantly share code, notes, and snippets.

@fujieda
Last active April 7, 2024 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujieda/bc86460d04c7256658c9fa2d99b55d2f to your computer and use it in GitHub Desktop.
Save fujieda/bc86460d04c7256658c9fa2d99b55d2f to your computer and use it in GitHub Desktop.
Switches to en-US when loading Microsoft documents from another language
// ==UserScript==
// @name Prefer English on Microsoft
// @namespace https://gist.github.com/fujieda/bc86460d04c7256658c9fa2d99b55d2f/raw
// @description Switches to en-US when loading Microsoft documents from another language
// @include https://learn.microsoft.com/*
// ==/UserScript==
var pattern = /(.*microsoft.com)\/([a-z]{2}-[a-z]{2})\/(.*)/i;
var replacement = "$1/en-us/$3";
var oldurl = window.location.href;
var newurl = oldurl.replace(pattern, replacement);
if (newurl != oldurl)
{
window.stop();
window.location.assign(newurl);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment