// ==UserScript==
// @name           MySpace MSPLinks Translator
// @namespace      Adrian232
// @description    Translates msplinks.com links on myspace pages to their original link, so you can see where you're going.
// @source         http://www.eternalbloodlust.com/gmscripts/myspacemsplinkstranslator.user.js
// @identifier     http://www.eternalbloodlust.com/gmscripts/myspacemsplinkstranslator.user.js
// @creator        Adrian (myspace.com/adrian232)
// @version        0.1
// @date           2007-09-23
// @include        *myspace.com/*
// ==/UserScript==
// Created by Adrian: http://www.myspace.com/adrian232

// Set to false if you don't want it to change the actual link
var change_link     = true;

// Set to true if you want a tooltip to pop up with the real link
var change_title    = false;

// Set to true if you want the link to switch back to msplinks
var switch_on_click = false;

(function Translate() {
	var links = document.getElementsByTagName("a");
	
	for (var i = 0; i < links.length; i++) {
		if (links[i].href && links[i].href.match(/https?:\/\/[0-9a-zA-Z\-\_]+\.msplinks\.com\//)) {
			var link = links[i];
			var orig = link.href;
			var url = atob(link.href.replace(/^.*msplinks\.com\//i, '')).replace(/^01/, '');
			GM_log(url);
			if (change_link)
				link.href = url;
			if (change_title)
				link.title += url;
			if (switch_on_click)
				; // not yet implemented
		}
	}
	
	// recursive, for any AJAX-ified pages (MySpace video comments)
	if (document.location && document.location.href && document.location.href.match(/\/vids\.myspace\.com\//))
		setTimeout(Translate, 2500);
})();
