Bookmarklets: Google Navigation

While on my recent bookmarklet excursion, I decided to tackle a bookmarklet that I've been wanting to do for a few years now, which is to go to the next search results page in Google.

Turns out it's MUCH easier that I though to accomplish by using the DOM to grab the actual next url:

javascript:location.href=document.getElementById('nn').parentNode;

Since that was so simple, I decided to try going back to a previous resutls page. It was a matter of finding the right div ID:

javascript:location.href=document.getElementById('np').parentNode;

I have only tested these in Safari, so your mileage may vary. I have these as the third and fourth bookmarks on my bookmarks bar, so I can hit command-3 to go to previous, and command-4 to go to the next set of results.

To add these bookmarklets to your browser, simply drag the links below to your bookmarks bar:

Bookmarklets: CD (Change Directory)

For quite a long time now, I've had a bookmarklet in the first position of my bookmarks bar in Safari which will load the web page above whatever page I am currently viewing. This can come in very handy when you land on a page from a search engine and you'd like to see what else might be on the site.

For example, say I am on FileMaker's website looking at documentation at

http://www.filemaker.com/developers/resources/documentation.html
When I click my bookmarklet, I end up at this url:
http://www.filemaker.com/developers/resources/
Click again, and end up at this url:
http://www.filemaker.com/developers/
And so on until I am at the root of the site:
http://www.filemaker.com/

There are times though, when walking through the path is needless because there are no viewable pages available. It just depends on the website. Because of this, I've wanted to find a new bookmarklet that simply goes to the root of the site. After googling for a while, I came up dry, so it was time to write my own. I did find some example bookmarklets that made it easy to figure out at http://jan.moesen.nu/code/browser/bookmarks, specifically the "CD .." bookmarklet.

Turns out it's so simple I don't know why I didn't try to do this earlier:

javascript:location='/';

The code to move up a directory is a little more complex, but not to difficult to follow:

javascript: 
   if (location.pathname == '/'); 
   else if (location.pathname.charAt(location.pathname.length - 1) == '/') location = '..';
   else location = '.';

I have only tested these in Safari, so your mileage may vary. One cool thing is you can use command-# for bookmarks on your toolbar, where # is the number of the bookmark from the left. I've named these " • " and " •• ", and they are the first and second bookmarks on my bookmark bar. So to get to the root of a site, I just hit command-1, and to walk up the directories I hit command-2.

To add these bookmarklets to your browser, simply drag the links below to your bookmarks bar:

...more entries
<- September 2010 ->
S M T W T F S

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30


Jesse.Traynham.com
π