PHP.net redirect to english

redirects to English version of the documentation

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         PHP.net redirect to english
// @namespace    https://greasyfork.org/en/scripts/40797-php-net-redirect-to-english
// @version      0.3.2
// @description  redirects to English version of the documentation
// @author       adamaru
// @match        http://php.net/manual/*
// @match        https://php.net/manual/*
// @match        http://*.php.net/manual/*
// @match        https://*.php.net/manual/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

/* jshint esversion: 6 */

(function() {
    'use strict';

    const url = window.location.href;
    const regex = /(https?:\/\/(?:[^\.]+\.)?php\.net\/manual\/)([^\/]+)(\/.*)/gm;
    const match = regex.exec(url);

    if(!match){
        return;
    }

    if(match[2] === 'en'){
        return;
    }

    const newUrl = match[1] + 'en' + match[3];
    window.location.replace(newUrl);
})();