Originally taken from http://www.elsewhere.org/journal/gmaptogpx/ version 6.4j: 2011.07.12
gMapToGPX is a simple bookmarklet that allows you to convert Google Maps driving directions into GPX format, which can then be used in a number of ways. I took on this project because the original version stopped working and has not been updated for some time. The problem is that the script is heavily coupled to Google Maps internal data structures and thus, when gMaps updates, it's possible that the script will stop working.
Please note that this utility is designed to work on Google Maps driving/walking directions directly as well as a number of sites that are are mashups of Google Maps. In my case, I originally did this because I wanted to load running maps from gmap-pedometer.com onto my Garmin.