February 10, 2012

Google site search, javascript bookmarklet

Google site search, javascript bookmarklet

Javascript iconI prepared this bookmarklet as a quick hack, and a little javascript exercise. There might be better and more advanced equivalent utilities and add-ons around.

The bookmark/favorites link runs a little script that prompts the user for search terms, and then performs a google search limited to the current site. Let's say you are visiting, and what to do a google search limiting only that site.

You can just click the link below to see it in action before you decide to add it as a bookmark/favorite.

To install the site search bookmarklet,
right click here and choose "add to bookmark" or equivalent,
or drag this link to a favorites/bookmarks bar

The bookmarklet is available for unrestricted download under a Creative Commons Attribution 3.0 Unported License. This gives you the right to redistribute and modify the script, as long as Nordpil is properly credited.

The code in the bookmarklet is:

/* global document,prompt */
var host = document.location.hostname.split('.');
if ( host.length > 2 ) {
host = host[host.length-2] + '.' + host[host.length-1];
} else {
document.location = '' +
prompt('Search term') + '+site:' + host;

Releases and versions

  • version 1.0, October 12, 2012


Post a Comment

Required Field