Skip to content

Instantly share code, notes, and snippets.

@tototoshi
Created July 12, 2011 01:16
Show Gist options
  • Save tototoshi/1077180 to your computer and use it in GitHub Desktop.
Save tototoshi/1077180 to your computer and use it in GitHub Desktop.
Googleの検索言語切り替え(en<->ja)ブックマークレット
javascript:void((function () {
var url = location.href;
var ja = url.search(/hl=ja/);
var en = url.search(/hl=en/);
if (url.search(/google\.(co\.jp|com)\/search/) < 0) return;
if (ja > 0) {
location.href = url.replace(/hl=ja/, "hl=en");
} else if (en > 0) {
location.href = url.replace(/hl=en/, "hl=ja");
} else {
var beginning_of_params = url.search(/\?/) + 1;
location.href = url.substr(0, beginning_of_params) + "hl=ja&" + url.substr(beginning_of_params);
}
})());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment