Source for "HTML Facebook Boombox"

By sizzlemctwizzle
Has 14 other scripts.


// ==UserScript==
// @name             HTML Facebook Boombox
// @description      Replace the Flash Facebook Boombox Application with HTML
// @include          http://apps.facebook.com/theboombox/user.php?id=*
// @include          http://apps.facebook.com/theboombox/search.php*
// @include          http://*.facebook.com/profile.php?id=*
// ==/UserScript==

function Get_Players() {
var dev = document.evaluate(
	'//div[@class="player_box"]', 
	document, 
	null, 
	XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);		
	

	var dev2 = document.evaluate(
	'//div[@class="boombox_media"]', 
	document, 
	null, 
	XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
if (dev.snapshotItem(0) == null) {
dev = dev2;
}
return dev;
}

function Get_HTML(flashvars) {
flashvars = decodeURIComponent(flashvars);
string = flashvars.split('<index>')[1].split('</index>')[0];
string = string.replace(/\+/g, ' ');
songs = string.split('<song>');
html = '';
for (var i = 1; i < songs.length; i ++) {
song = songs[i].split('</song>')[0];
title = song.split('<title>')[1].split('</title>')[0];
artist = song.split('<artist>')[1].split('</artist>')[0];
url = song.split('<size>')[1].split('</size>')[0];
id = song.split('<id>')[1].split('</id>')[0];
          if (url.substr(0, 7) != 'http://') {
            url = 'http://' + url;
          }
          if ((url.substr(-4)).toUpperCase() != '.MP3') {
            url += '.mp3';
          }

html = html + '<tr padding="5px" width="100%"><td align="left"><a href="' + url + '" target="_blank">' + title + ' / ' + artist + '</a>';
if (document.getElementById('box_app_2373783402') == null) {
html = html + '</td><td align="right"><a href="http://apps.facebook.com/theboombox/actions/add_existing_song.php?song=' + id + '&redirect=myboombox%2Ephp">Add Song</a></td></tr>';
} else {
html = html + ' | <a href="http://apps.facebook.com/theboombox/actions/add_existing_song.php?song=' + id + '&redirect=myboombox%2Ephp">Add Song</a></td></tr>';
}
}
return html;
}

if (!document.getElementById('box_app_2373783402')) {
window.addEventListener('load',function () {
dev = Get_Players();
if (dev.snapshotItem(0)) {
div = dev.snapshotItem(0).firstChild;
player = dev.snapshotItem(0).firstChild.firstChild;
flashvars = player.getAttribute('flashvars');
div.innerHTML = '<table width="100%">' + Get_HTML(flashvars) + '</table>';
}
},false)
} else {

var dev = document.evaluate(
	'//div[@class="wide_track"]', 
	document, 
	null, 
	XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < dev.snapshotLength; i ++) {
div = dev.snapshotItem(i);
player = dev.snapshotItem(i).firstChild.firstChild.firstChild;
flashvars = player.getAttribute('flashvars');
div.innerHTML = Get_HTML(flashvars);
div.setAttribute('style', 'background:none;border:none;');
}
dev.snapshotItem(0).parentNode.innerHTML = '<table width="350px">' + dev.snapshotItem(0).parentNode.innerHTML + '</table>';
}