MySpace Extra Links

By JoeSimmons Last update Jun 14, 2009 — Installed 339 times. Daily Installs: 1, 1, 3, 2, 2, 3, 0, 1, 4, 4, 0, 1, 1, 1, 2, 1, 0, 2, 1, 1, 1, 0, 0, 1, 1, 2, 4, 0, 0, 1, 1, 1

There are 3 previous versions of this script.

// ==UserScript==
// @name           MySpace Extra Links
// @namespace      http://userscripts.org/users/23652
// @description    Adds extra links to the profile's dropdown menu like comments and friends
// @include        http://*.myspace.com/*
// @copyright      JoeSimmons
// @version        1.0.0
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// ==/UserScript==

// Create by avg, modified by JoeSimmons
function create(a,b) {
	var ret=document.createElement(a);
	if(b) for(var prop in b) {
		if(prop.indexOf('on')==0) ret.addEventListener(prop.substring(2),b[prop],false);
		else if(prop=="kids" && (prop=b[prop])) {
			for(var i=0;i<prop.length;i++) ret.appendChild(prop[i]);
		}
		else if('style,accesskey,id,name,src,href,class'.indexOf(prop)!=-1) ret.setAttribute(prop, b[prop]);
		else ret[prop]=b[prop];
	}  return ret;
}

if(!unsafeWindow.MySpace || !unsafeWindow.MySpace.ClientContext || top.location!=location) return;

var drop = document.evaluate("//ul[@id='subNav2500000' or @id='nav2500000'] | //li[@id='subNav2500000' or @id='nav2500000']",document,null,9,null).singleNodeValue,
	id = unsafeWindow.MySpace.ClientContext['DisplayFriendId']||(window.location.href.match(/friendID=([^&])/)||'')[1]||false;
if(drop && drop.tagName.toLowerCase()!='ul') drop = document.evaluate(".//ul",drop,null,8,null).singleNodeValue;

if(!id || id=='' || !drop) {return;}

if(drop.lastChild.className=='last') drop.lastChild.removeAttribute('class');
drop.appendChild(create('li', {style:'width: 140px;', kids:new Array(
create('a', {style:'width: 125px;', textContent:'Comments', href:'http://comment.myspace.com/index.cfm?fuseaction=user.viewComments&friendID='+id})
)}));
drop.appendChild(create('li', {style:'width: 140px;', kids:new Array(
create('a', {style:'width: 125px;', textContent:'Friends', href:'http://friends.myspace.com/index.cfm?fuseaction=user.viewfriends&friendID='+id})
)}));