I had written about how to get started with a greasemonkey. It was a simple small script on how to change the google logo with your font. It showed you how to install greasemonkey and write your first script. This is possibly a second DO IT YOURSELF (DIY), which will play more with google search, obviously with the greasemonkey.
1. Install greasemonkey, you may see it in the download list of this website. Additionally you may take help from the post, which should have been called - getting started with greasemonkey.
2. Assuming that you are ready to code in top gear, i am starting off with the include patterns for this script.Without doubt, google is (one of) the best search engine(s). I must consider myself silly if i am telling you the google url. But just in case you noted this, the google search engine result page is http://google.com/search?q=your%20search%keyword.
// ==UserScript==
// @name googleNewtab
// @description Opens google search result in new tab
// @include *google.com/search*
// ==/UserScript==
You should have noticed that the search is the context and q is a part of query string (the one that follows a ‘?’. Actually q is the name of the search box.) . The last three words makes up your search keyword(literally!). So your include pattern can read something like http://*google.com/search*
You could have noticed that the first * is for the www, which i prefer to omit. The second * in the expression indicates that any other string could follow.
3. Lets get our hands dirty, just in case you do not have firebug, i feel you must get it before writing a greasemonkey. Firebug to a developer is like a knife to a chef.
4. First lets remove the ads in the page. how to remove google ads in google search?You must use firebug to detect the ads.
Here is a snippet of code, which will remove adsense from google search result page.
var ads = document.getElementById (’mbEnd’);if (ads){ads.parentNode.removeChild (ads);}
Similarly, you can remove the ads in the sidebar, using a similar script.
var spons = document.getElementById (’tads’);if (spons){spons.parentNode.removeChild (spons);}
There are three things that a developer must notice here.
1. Always try to use getElementById, rather than other choices like getElementsByTagName or getElementByClass. This would require the element to be present in a div or as a table.
2. Check for the object reference before taking an action. (The if block serves this good)
3. Use parent node to delete a node. Imagine this in lay man terms. You can drop a bedroom from a house, a house from a street. Always use parent node to perform actions on nodes.Looks like a little more code can add some fun. Try adding a link to every search result, which will open in the next tab. (You can do this with a right click -> open in new tab or with the help of ctrl + click)
Download the full script - google new tab greasemonkey script

A few more ideas:
1. Try listing the search results with numbers.
2. Omit duplicate results, you can do this by removing the duplicate results (these are indented, like the one in the image above.)
3. You can get the website logo and prefix it before the link.
4. You can display the pagerank for every link. (This may help you see what page rank is required to top the search results) .If you have your own code or just an idea (i like this) , i would appreciate if you can let us know.




1 user commented in " greasemonkey code for google search "
Follow-up comment rss or Leave a Trackback[…] people are busy playing with what appeared aside of the customize google search results, google has let users play with the search results […]
Leave A Reply - Opinionate..