mafrasi2 / Redirect to english cppreference

// ==UserScript==
// @name         Redirect to english cppreference
// @version      1.1
// @description  Redirects cppreference translations to the english original
// @match        http://*.cppreference.com/*
// @match        https://*.cppreference.com/*
// @copyright    2018, Max Sistemich
// @license      MIT
// ==/UserScript==

var old_href = document.location.href;
if (!old_href.startsWith("http://en.cppreference.com") && !old_href.startsWith("https://en.cppreference.com")) {
  var new_href = old_href.replace(/^(http|https):\/\/[^\/]+\//, function(_, protocol) {
      return protocol + '://en.cppreference.com/'
  });
  document.location.href = new_href;
}