Created
May 7, 2010 10:41
-
-
Save stanaka/393274 to your computer and use it in GitHub Desktop.
This file contains 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
function do_insert_html(doc, type, element, html) { | |
var new_element = doc.createElement(type); | |
new_element.innerHTML = html; | |
element.parentNode.insertBefore(new_element, element); | |
}; | |
function engine(name, link,img) { | |
this.link = link; | |
this.img = img; | |
this.name = name; | |
} | |
var form = document.forms.namedItem("gs"); | |
var input = form.elements.namedItem("q"); | |
var eq = encodeURI(input.value); | |
var engines = new Array(); | |
engines.push(new engine("Google for Japanese", | |
"http://www.google.com/search?q=%1&ie=UTF-8&lr=lang_ja", | |
"http://www.google.com/favicon.ico")); | |
engines.push(new engine("Google for English", | |
"http://www.google.com/search?q=%1&ie=UTF-8&lr=lang_en", | |
"http://www.google.com/favicon.ico")); | |
engines.push(new engine("Twitter Search", | |
"http://search.twitter.com/search?q=%1", | |
"http://a1.twimg.com/a/1273181936/images/favicon.ico")); | |
engines.push(new engine("Yahoo for Japanese", | |
"http://search.yahoo.co.jp/bin/search?p=%1", | |
"http://www.yahoo.com/favicon.ico")); | |
engines.push(new engine("Yahoo for English", | |
"http://search.yahoo.com/search?p=%1&ei=UTF-8", | |
"http://www.yahoo.com/favicon.ico")); | |
engines.push(new engine("Hatena Bookmark Search", | |
"http://b.hatena.ne.jp/search?q=%1", | |
"http://b.hatena.ne.jp/favicon.ico")); | |
var header = null; | |
var elems = document.getElementsByTagName("li"); | |
for (var i = 0; i < elems.length; i++) { | |
if(elems[i].className == 'tbou'){ | |
header = elems[i].parentNode; | |
break; | |
} | |
} | |
if (header != null){ | |
var html = ''; | |
var cur; | |
while(cur = engines.shift()){ | |
var tmp_html = cur.link; | |
tmp_html = tmp_html.replace(/%1/g, eq); | |
html += '<li class=tbou><a href="' + tmp_html + '">'; | |
if(cur.img){ | |
html += '<img width=16 height=16 border=0 src="' + cur.img + '">'; | |
} | |
html += cur.name + '</a></li>'; | |
} | |
html = '<ul class="tbt tbpd">' + html + '</ul>'; | |
do_insert_html(document, "span", header, html); | |
}; | |
// ==UserScript== | |
// @name Add Search Links for Google | |
// @namespace http://d.hatena.ne.jp/stanaka/ | |
// @description Add links of other search engines to sidebar of Google search results | |
// @include http://www.google.*/search?* | |
// ==/UserScript== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment