Google ByCycle

By Dave Sohigian Last update Feb 25, 2008 — Installed 149 times.
// ==UserScript==
// @author		  Dave Sohigian
// @name          Google ByCylce
// @description   Adds a link to google maps
// @include*
// Adapted by Dave Sohigian,
// Licensed under the GNU General Public License (GPL)
// Version 0.1  - 25th, Februrary, 2008
// Hey, it only works in Portland, OR right now. If you are from Milwaukee (the other place that works on
// then it will need to be modified. Contact me at if you have a gripe.

if (
document.documentElement.tagName == "HTML"
&& document.contentType == "text/html"
&& document.body    // Basic sanity
) {

function getUrl() {
	//This function create the full URL for the site.
	//if we are on a google maps directions page we should have the "d_daddr" element
	if (document.getElementById('d_daddr')){
		//Build the URL required by
		getUrl = ";find?s="
		//Start Address (this value comes directly from the input field in google maps)
		getUrl += escape(document.getElementById('d_d').value);
		getUrl += "&e=";
		//End Address
		getUrl += escape(document.getElementById('d_daddr').value);
		getUrl += "&pref=default";
		return getUrl;


function createLink (a) {
	// This function defines the parameters of the link
	a.setAttribute('title',"Get directions by");
	a.setAttribute('target',"_blank"); = 'bold';
	return a;

function run () {
	//create the link element
	var a = document.createElement('a');
	//find the "print" link on the Google page where we will insert the new link
	var node = document.getElementById('print');
	// HTML for the link
	a.innerHTML = '<a href="#">Go ByCycle</a>';
	//create the link (mainly grabbing the "from" and "to" parameters and encoding
	a = createLink(a);
	//insert the link
	node.parentNode.insertBefore(a, node);