Austinbabe / Gwent Deck Page Language Redirector

// ==UserScript==
// @name         Gwent Deck Page Language Redirector
// @namespace    Who cares
// @version      1.0
// @description  Redirector the Langauge
// @author       Austin Kuo
// @match        *://www.playgwent.com/*
// @supportURL   https://www.google.com.tw/
// @icon         https://www.google.com/s2/favicons?domain=playgwent.com
// @grant        none
// @license MIT
// ==/UserScript==
/*
You can change the language by changing the content below;
  list below 
  1. 'en' => English
  2. 'ru' => Russian
  3. 'ja' => Japenese
  4  'kr' => Korean
 */

//Global Variable
const lang = 'en'; // <== Change here

(function () {
	'use strict';

	// Your code here...
	window.addEventListener(
		'load',
		() => {
			resetURL();
		},
		false
	);
})();

const resetURL = () => {
	let url = window.location.href;
	let array = url.split('/');
	if (url.indexOf('decks') > 0 && array[3] != lang) {
		array[3] = lang;
		array.slice(2, array.length);
		window.location.href = array.join('/');
	}
};