matheusfaustino / Mozilla Dev Website Always Eng

// ==UserScript==
// @name        Mozilla Dev Website Always Eng
// @namespace   mozilla.dev.docs.always.eng
// @author matheusfaustino
// @description Always change the language of mozilla docs to English
// @include     https://developer.mozilla.org/*/docs/*
// @exclude     https://developer.mozilla.org/en*/docs/*
// @version     1
// @grant       none
// ==/UserScript==

function changeToEnglish() {  
  let languages = [].slice.call(document.querySelectorAll('#languages-menu-submenu ul li a'));  
  let english_url = '';    
  
  for(let i=0; i < languages.length && !english_url; i++)    
    if (languages[i].getAttribute('href').indexOf('en-US') != -1)      
      english_url = languages[i].getAttribute('href');   
  
  window.location.replace(english_url);
}

document.addEventListener('DOMContentLoaded', () => changeToEnglish() );