Restore the Read in English button at docs.microsoft.com
// ==UserScript==
// @name Restore Read in English button
// @namespace http://qpwakaba.xyz/
// @version 0.12
// @description Restore the Read in English button at docs.microsoft.com
// @author King (qpwakaba)
// @match https://docs.microsoft.com/*
// @grant none
// @run-at document-body
// ==/UserScript==
(function() {
'use strict';
if (document.getElementById('language-toggle')) return;
var pageActionsElements = document.getElementsByClassName('action-list');
if (pageActionsElements.length === 0) return;
var menu = pageActionsElements[0];
var switchLang = document.createElement('li');
switchLang.innerHTML = '<div class="lang-toggle-container" style="display: flex;"><label for="language-toggle" aria-hidden="true" tabindex="-1" class="x-hidden-focus">Read in English</label><div class="checkbox-toggle-wrapper"><input type="checkbox" id="language-toggle" aria-label="Read in English" data-m="{"cN":"language-toggle","value":"off"}"><label for="language-toggle" class="switch"></label></div></div>'
if (menu.children.length >= 5) {
menu.insertBefore(switchLang, menu.children[4]);
} else {
menu.appendChild(switchLang);
}
})();