Steam - Default language

Make sure you always see the steam page in your preferred language. You can configure the language in the language variable.

Stan na 04-05-2016. Zobacz najnowsza wersja.

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

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

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         Steam - Default language
// @version      0.3
// @description  Make sure you always see the steam page in your preferred language. You can configure the language in the language variable.
// @author       Royalgamer06
// @include      /(http|https)\:\/\/(.+\.steampowered|steamcommunity)\.com.*/
// @run-at       document-start
// @grant        none
// @namespace    https://greasyfork.org/users/13642
// ==/UserScript==

//SET YOUR LANGUAGE HERE
var language = "en";
/*
bulgarian: bg,
czech: cs,
danish: da,
dutch: nl,
finnish: fi,
french: fr,
greek: el,
german: de,
hungarian: hu,
italian: it,
japanese: ja,
koreana: ko,
norwegian: no,
polish: pl,
portuguese: pt-PT,
brazilian: pt-BR,
russian: ru,
romanian: ro,
schinese: zh-CN,
spanish: es-ES,
swedish: sv-SE,
tchinese: zh-TW,
thai: th,
turkish: tr,
ukrainian: uk
*/

//DO NOT TOUCH BELOW
window.onload = function() {
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        if (anchors[i].href.indexOf("l=" + language) == -1 && (anchors[i].href.indexOf("steamcommunity") > -1 || anchors[i].href.indexOf("steampowered") > -1)) {
            anchors[i].href = addParameter(anchors[i].href, "l", language, false);
        }
    }
};

if (location.href.indexOf("l=" + language) == -1) {
    location.href = addParameter(location.href, "l", language, false);
}

//Nice solution from http://stackoverflow.com/a/6954277/4356020
function addParameter(url, parameterName, parameterValue, atStart) {
    replaceDuplicates = true;
    var cl = "";
    if(url.indexOf('#') > 0){
        cl = url.indexOf('#');
        urlhash = url.substring(url.indexOf('#'),url.length);
    } else {
        urlhash = '';
        cl = url.length;
    }
    sourceUrl = url.substring(0,cl);

    var urlParts = sourceUrl.split("?");
    var newQueryString = "";

    if (urlParts.length > 1)
    {
        var parameters = urlParts[1].split("&");
        for (var i=0; (i < parameters.length); i++)
        {
            var parameterParts = parameters[i].split("=");
            if (!(replaceDuplicates && parameterParts[0] == parameterName))
            {
                if (newQueryString === "")
                    newQueryString = "?";
                else
                    newQueryString += "&";
                newQueryString += parameterParts[0] + "=" + (parameterParts[1]?parameterParts[1]:'');
            }
        }
    }
    if (newQueryString === "")
        newQueryString = "?";

    if(atStart){
        newQueryString = '?'+ parameterName + "=" + parameterValue + (newQueryString.length>1?'&'+newQueryString.substring(1):'');
    } else {
        if (newQueryString !== "" && newQueryString != '?')
            newQueryString += "&";
        newQueryString += parameterName + "=" + (parameterValue?parameterValue:'');
    }
    return urlParts[0] + newQueryString + urlhash;
}