fardjad / Google in English PLEASE!

// ==UserScript==
// @namespace     https://openuserjs.org/users/fardjad
// @name          Google in English PLEASE!
// @description   Forces Google Products' language to en-US by adding an hl querystring parameter to URLs.
// @copyright     2018, Fardjad Davari (https://openuserjs.org/users/fardjad)
// @author        Fardjad Davari
// @license       MIT
// @version       1.2.1
// @include       http*://*.google.*
// @grant         none
// ==/UserScript==

// ==OpenUserJS==
// @author fardjad
// ==/OpenUserJS==

(function () {
  'use strict';

  const ignoredDomains = ["translate.google.com", "docs.google.com", "accounts.google.com"];

  const urlParams = new URLSearchParams(window.location.search);
  const hl = urlParams.get('hl');

  if (hl == null) {
    urlParams.append('hl', 'en-US');
    const {
      protocol,
      host,
      pathname,
      hash
    } = window.location;

    if (ignoredDomains.includes(host)) {
      return;
    }

    window.location.replace(protocol + '//' + host + pathname + '?' + urlParams.toString() + hash);
  }
})();