Steam - Default language

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

  1. // ==UserScript==
  2. // @name Steam - Default language
  3. // @version 1.4
  4. // @description Make sure you always see the steam page in your preferred language. You can configure the language in the language variable.
  5. // @author Royalgamer06
  6. // @include /^https?\:\/\/(store\.steampowered|steamcommunity)\.com.*/
  7. // @run-at document-start
  8. // @grant none
  9. // @namespace https://greasyfork.org/users/13642
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.js
  11. // ==/UserScript==
  12.  
  13. //SET YOUR LANGUAGE HERE
  14. const strTargetLanguage = "english"; //bulgarian, czech, danish, dutch, finnish, french, greek, german, hungarian, italian, japanese, koreana, norwegian, polish, portuguese, brazilian, russian, romanian, schinese, spanish, swedish, tchinese, thai, turkish, ukrainian
  15. const bStayOnPage = false; //true, false
  16.  
  17. //DO NOT TOUCH BELOW
  18. this.$ = this.jQuery = jQuery.noConflict(true);
  19. if (getURIParam("l") !== strTargetLanguage && !!getURIParam("l")) {
  20. window.location.search = setURIParam("l", strTargetLanguage);
  21. } else {
  22. var cookie = document.cookie;
  23. var language;
  24. $("script[src]").each(function() {
  25. var match = this.src.match(/(?:\?|&(?:amp;)?)l=([^&]+)/);
  26. if (match) {
  27. language = match[1];
  28. return false;
  29. }
  30. });
  31. if (language === undefined) {
  32. language = (cookie.match(/steam_language=([a-z]+)/i) || [])[1] || "english";
  33. }
  34. if (language.toLowerCase() !== strTargetLanguage.toLowerCase()) {
  35. //ChangeLanguage(strTargetLanguage, bStayOnPage);
  36. $.post((location.hostname == "steamcommunity.com" ? "/actions/SetLanguage" : "/account/setlanguage"), { language: strTargetLanguage, sessionid: g_sessionID }, function() {
  37. if (location.hostname == "store.steampowered.com") {
  38. $.post("//store.steampowered.com/account/savelanguagepreferences", {"primary_language": strTargetLanguage, "secondary_languages[]": strTargetLanguage, "sessionid": g_sessionID }, function() {
  39. if (!bStayOnPage) location.href = location.href.replace(/l\=[a-zA-Z]+&?/, "");
  40. });
  41. } else {
  42. if (!bStayOnPage) location.href = location.href.replace(/l\=[a-zA-Z]+&?/, "");
  43. }
  44. });
  45. }
  46. }
  47. function getURIParam(sParam) {
  48. var sPageURL = decodeURIComponent(window.location.search.substring(1).toLowerCase()),
  49. sURLVariables = sPageURL.split("&"),
  50. sParameterName,
  51. i;
  52. for (i = 0; i < sURLVariables.length; i++) {
  53. sParameterName = sURLVariables[i].split("=");
  54. if (sParameterName[0] === sParam) {
  55. return sParameterName[1] === undefined ? true : sParameterName[1];
  56. }
  57. }
  58. }
  59. function setURIParam(keyString, replaceString) {
  60. var query = decodeURIComponent(window.location.search.substring(1).toLowerCase()),
  61. vars = query.split("&"),
  62. replaced = false,
  63. i;
  64. for (i = 0; i < vars.length; i++) {
  65. var pair = vars[i].split("=");
  66. if (pair[0] == keyString) {
  67. vars[i] = pair[0] + "="+ replaceString.toLowerCase();
  68. replaced = true;
  69. }
  70. }
  71. if (!replaced) vars.push(keyString.toLowerCase() + "=" + replaceString.toLowerCase());
  72. return vars.join("&");
  73. }