Last.fm Clickable Username and Avatar

By syntax Last update Sep 28, 2008 — Installed 859 times. Daily Installs: 0, 1, 0, 2, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1

There are 2 previous versions of this script.

// ==UserScript==
// @name		Last.fm Clickable Username and Avatar
// @namespace	http://straylight.cz/userscripts/
// @description	Makes username and avatar on user page clickable as in the old version of Last.fm.
// @version		0.4
// @date		2008-07-27
// @include	http://*.last.fm/user/*
// @include	http://www.lastfm.*/user/*
// @exclude	http://*.last.fm/user/*/*
// @exclude	http://www.lastfm.*/user/*/*
// ==/UserScript==
// Changelog
// 0.4 (2008-07-27) Fix for changes on Last.fm site
// 0.3 (2008-07-24) Support for Firefox 2 (TODO: Drop it on December)
// 0.2 (2008-07-23) Added target for username
// 0.1 (2008-07-22) Initial version, only for avatar

if(typeof document.getElementsByClassName != 'function')
{
	// Fx2 doesn't support getElementsByClassName, so we use Prototype's
	getElementsByClassName = unsafeWindow['document'].getElementsByClassName;
	//GM_log('Using Prototype function.');
}
else
{
	// Wrap the native function (In Gecko since v1.9).
	getElementsByClassName = document.getElementsByClassName;
	//GM_log('Using native function.');
}

(function()
{
var userBadge = document.getElementById('userBadge');
if(!userBadge)
	return;

var img = userBadge.getElementsByClassName('badgeAvatar')[0];
var heading = userBadge.getElementsByTagName('h1')[0];
if(!(img && heading))
	return;

var target = window.location.href;
img.innerHTML = '<a href="'+target+'">'+img.innerHTML+'</a>';
heading.innerHTML = '<a href="'+target+'" style="color: #000">'
	+heading.innerHTML+'</a>';
})();