03 August, 2013

UserJS: Google search inside a specific website

   Use this User JS.  The script asks for the search word and a website (it uses the selected word and  the current website as default).



Google_Site_search=function(){
var word=window.getSelection().toString();
var site=window.location.hostname.toString();
word=window.prompt('Search word',word);
site=window.prompt('Search in website',site);
var url='http://www.google.com/search?q='+ encodeURI(word +'+site:' +site);
window.open(url, '_blank');
}
... and call this script with this shortcut or a mouse gesture:

Ctrl G=Enable javascript & Delay, 10 & Go to page,"javascript:Google_Site_search()"



Or use it as a bookmarklet:

javascript:(function(){var word=window.getSelection().toString();var site=window.location.hostname.toString(); word=window.prompt('Search word',word);site=window.prompt('Search in website',site);var url='http://www.google.com/search?q='+ encodeURI(word +'+site:' +site); window.open(url, '_blank');})()

No comments:

Post a Comment