Created
February 23, 2011 16:17
-
-
Save hail2u/840633 to your computer and use it in GitHub Desktop.
Googleの検索結果ページに「英語のページを検索」というリンクを追加し、簡単に英語のページからのみ検索できるようにする。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Google: Add "Search English pages" link | |
// @namespace http://hail2u.net/ | |
// @description Googleの検索結果ページに「英語のページを検索」というリンクを追加し、簡単に英語のページからのみ検索できるようにする。 | |
// @include http://www.google.com/search?* | |
// ==/UserScript== | |
var label = "英語のページを検索"; | |
var url = location.toString(); | |
if (url.indexOf("lr=") < 0) url += "&lr=lang_ja"; | |
if (document.getElementById("lr_lang_1ja")) { | |
url = url.replace("lr=lang_ja", "lr=lang_en"); | |
} else if (document.getElementById("lr_lang_1en")) { | |
label = "日本語のページを検索"; | |
url = url.replace("lr=lang_en", "lr=lang_ja"); | |
} else { | |
url = undefined; | |
} | |
if (url) { | |
var li = document.createElement("li"); | |
li.setAttribute("class", "tbou"); | |
var a = document.createElement("a"); | |
a.href = url; | |
a.innerText = label; | |
li.appendChild(a); | |
document.getElementById("lr_").parentNode.appendChild(li); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment