Steam - Default language

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

目前为 2017-01-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Steam - Default language
  3. // @version 1.2
  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-idle
  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. var cookie = document.cookie;
  19. var language;
  20. $("script[src]").each(function() {
  21. var match = this.src.match(/(?:\?|&(?:amp;)?)l=([^&]+)/);
  22. if (match) {
  23. language = match[1];
  24. return false;
  25. }
  26. });
  27. if (language === undefined) {
  28. language = (cookie.match(/steam_language=([a-z]+)/i) || [])[1] || "english";
  29. }
  30. if (language.toLowerCase() !== strTargetLanguage.toLowerCase()) {
  31. //ChangeLanguage(strTargetLanguage, bStayOnPage);
  32. $.post((location.hostname == "steamcommunity.com" ? "/actions/SetLanguage" : "/account/setlanguage"), { language: strTargetLanguage, sessionid: g_sessionID }, function() {
  33. if (location.hostname == "store.steampowered.com") {
  34. $.post("//store.steampowered.com/account/savelanguagepreferences", {"primary_language": strTargetLanguage, "secondary_languages[]": strTargetLanguage, "sessionid": g_sessionID }, function() {
  35. if (!bStayOnPage) location.href = location.href.replace(/l\=[a-zA-Z]+&?/, "");
  36. });
  37. } else {
  38. if (!bStayOnPage) location.href = location.href.replace(/l\=[a-zA-Z]+&?/, "");
  39. }
  40. });
  41. }