Skip to content

Instantly share code, notes, and snippets.

@stanaka
Created May 7, 2010 12:17
Show Gist options
  • Save stanaka/393340 to your computer and use it in GitHub Desktop.
Save stanaka/393340 to your computer and use it in GitHub Desktop.
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/search?p=%1&ei=UTF-8",
"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("Bing",
"http://www.bing.com/search?q=%1",
"http://www.bing.com/s/wlflag.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 = document.evaluate( 'id("leftnav")/div[2]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
header = header.singleNodeValue.firstChild.nextSibling;
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 = '<li><ul class="tbt tbpd">' + html + '</ul></li>';
var new_element = document.createElement("ul");
new_element.className = "med";
new_element.id = "tbd";
new_element.innerHTML = html;
header.parentNode.insertBefore(new_element, header);
};
// ==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==
@Korb
Copy link

Korb commented Oct 7, 2023

What exactly does this script do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment