There are 1 previous version of this script.
// Google Dual Index 1.5
// Sean LeBlanc
// http://sean-leblanc.blogspot.com
// Contact seanleblanc AT comcast DOT net
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// To install, you need Greasemonkey: http://greasemonkey.mozdev.org/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Google Dual Index 1.5", and click Uninstall.
// --------------------------------------------------------------------
//
// WHAT IT DOES:
//
// Puts google index on top of page, too.
// --------------------------------------------------------------------
//
// ==UserScript==
// @name Google Dual Index 1.5
// @namespace http://sean-leblanc.blogspot.com
// @description Puts index of results pages on the top of the page as well.
// @include http://*.google.*
//
// @version 1.5 Updated to be able to find navigation.
// History:
// 1.5 - Updated to be able to find navigation.
// 1.4 - Updated to fix blog search - was inserting after first result.
// 1.3 - Updated to work on main page; added blogsearch.
// TODO: Do blogger search.
// ==/UserScript==
var debug = false;
var WEB = 0;
var IMAGES = 1;
var GROUPS = 2;
var NEWS = 3;
var FROOGLE = 4;
var BLOG = 5;
var searchType = -1;
// Simplify evaluate call:
function xpathFirst(query, node) {
if (!node) {
node = document;
}
var result = document.evaluate(query, node, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!result) {
return;
}
return result.singleNodeValue;
}
// Set search type of the current google page:
function setSearchType() {
if (window.location.href.match(/www\.google/)) {
searchType = WEB;
}
else if (window.location.href.match(/images\.google/)) {
searchType = IMAGES;
}
else if (window.location.href.match(/groups\.google/)) {
searchType = GROUPS;
}
else if (window.location.href.match(/news\.google/)) {
searchType = NEWS;
}
else if (window.location.href.match(/froogle\.google/)) {
searchType = FROOGLE;
}
else if (window.location.href.match(/blogsearch\.google/)) {
searchType = BLOG;
}
}
// Find the index of results:
function findIndexDiv() {
var id = null;
if (searchType==GROUPS) {
id = xpathFirst("//table[@id=\"bottom\_marker\"]");
}
else {
id = xpathFirst("//table[@id=\"nav\"]");
//id = xpathFirst("//div[@class=\"n\"]");
}
return id;
}
// Find element we should place copy of search index before:
function findTopDiv() {
var td = null;
slog("Search type = " + searchType);
if (searchType == WEB) {
//tableList = document.evaluate("//body//table[@width=\"100%\"]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
//td = tableList.snapshotItem(3);
//td = xpathFirst("//p[@class=\"g\"]");
slog("Searching for div/div, class=g.");
td = xpathFirst("//div//div[@class=\"g\"]");
td = td.parentNode;
}
else if (searchType == IMAGES) {
td = xpathFirst("//div[@id=\"ImgContent\"]");
slog("Images top div found.");
}
else if (searchType == NEWS) {
td = xpathFirst("//body//table[@align=\"right\"]");
}
else if (searchType == GROUPS) {
var tbl = xpathFirst("//div[@id=\"cbdy\"]//div//table");
//if (debug && tbl) GM_log("tbl found.");
td = tbl.nextSibling.nextSibling;
}
else if (searchType == FROOGLE) {
if (debug) GM_log("froog search.");
td = xpathFirst("//table//tbody//tr[@class=\"bc\"]");
//if (debug && td) GM_log("froogle td found.");
}
else if (searchType == BLOG) {
//td = xpathFirst("//p[@class=\"g\"]");
td = xpathFirst("//a[@id=\"p-1\"]");
}
return td;
}
setSearchType();
slog("About to find index div.");
var indexDiv = findIndexDiv();
if (indexDiv) {
slog("Found index div; about to find top div.");
var topDiv = findTopDiv();
if (topDiv) {
slog("Found top div.");
var parentDiv = topDiv.parentNode;
var newDiv = indexDiv.cloneNode(true);
if (searchType==FROOGLE) {
var newTr = document.createElement("tr");
var newTd = document.createElement("td");
parentDiv.insertBefore(newTr, topDiv.nextSibling);
newTd.setAttribute("colspan", "3");
newTr.appendChild(newTd);
newTd.appendChild(newDiv);
}
else {
//parentDiv.insertBefore(newDiv, topDiv.nextSibling);
parentDiv.insertBefore(newDiv, topDiv);
}
}
}
function slog(writeThis) {
if (debug) { GM_log(writeThis); }
}
