Google-Maps-Language-Switcher

A Greasemonkey/Tampermonkey script which let you switch the interface language of Google Maps quickly.

  1. // ==UserScript==
  2. // @name Google-Maps-Language-Switcher
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description A Greasemonkey/Tampermonkey script which let you switch the interface language of Google Maps quickly.
  6. // @author Observer
  7. // @include /^https?\:\/\/www\.google\..+\/maps/
  8. // @grant none
  9. // ==/UserScript==
  10. /* jshint -W097 */
  11. 'use strict';
  12.  
  13. (function () {
  14. function setGetParameter(paramName, paramValue)
  15. {
  16. var url = window.location.href;
  17. var hash = location.hash;
  18. url = url.replace(hash, '');
  19. if (url.indexOf(paramName + "=") >= 0)
  20. {
  21. var prefix = url.substring(0, url.indexOf(paramName));
  22. var suffix = url.substring(url.indexOf(paramName));
  23. suffix = suffix.substring(suffix.indexOf("=") + 1);
  24. suffix = (suffix.indexOf("&") >= 0) ? suffix.substring(suffix.indexOf("&")) : "";
  25. url = prefix + paramName + "=" + paramValue + suffix;
  26. }
  27. else
  28. {
  29. if (url.indexOf("?") < 0)
  30. url += "?" + paramName + "=" + paramValue;
  31. else
  32. url += "&" + paramName + "=" + paramValue;
  33. }
  34. window.location.href = url + hash;
  35. }
  36. if (!window.location.href.match(/hl=ja/)) {
  37. setGetParameter("hl", "ja")
  38. }
  39. })();