// Add a link to the FoRB group to mybubble.
// Version 0.1
// 2008-07-16
// Copyright (c) 2008, Dave Pearson <http://www.davep.org/>
// Released under the GPL
// http://www.gnu.org/copyleft/gpl.html
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.  To install it, you need
// Greasemonkey: http://www.greasespot.net/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "Promote RedBubble", and click Uninstall.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name          FoRB Link
// @namespace     http://www.davep.org/
// @description   Add a link to the FoRB group to mybubble.
// @include       http://www.redbubble.com/mybubble
// @include       http://www.redbubble.com/mybubble/
// ==/UserScript==

////////////////////////////////////////////////////////////////////////////
// Helper function to find an element by its tag and classname.
function getElementByTagNameAndClass( tag, classname )
{
   var hit  = null;
   var tags = document.getElementsByTagName( tag );

   for ( i = 0; i < tags.length; i++ )
   {
      if ( tags[ i ].className == classname )
      {
         hit = tags[ i ];
         break;
      }
   }

   return hit;
}

// Look for the quick links.
var links = getElementByTagNameAndClass( 'ul', 'quick-links' );

// Did we get it?
if ( links )
{
   // Create the new elements.
   var li   = document.createElement( 'li' );
   var forb = document.createElement( 'a' );

   // Set up the link.
   forb.setAttribute( 'href', 'http://www.redbubble.com/groups/friends-of-redbubble/forums/2011' );
   forb.innerHTML = 'FoRB';

   // Stuff the link into the list item.
   li.appendChild( forb );

   // Add it to the quick links.
   links.appendChild( li );

   // Don't ask. No, really. Don't ask.
   links.innerHTML = links.innerHTML;
}
