MySpace Picenlarge++

By jumper4000 Last update Jun 15, 2008 — Installed 4,733 times. Daily Installs: 2, 1, 5, 2, 3, 1, 4, 5, 5, 5, 3, 3, 1, 6, 4, 4, 0, 5, 1, 0, 0, 2, 1, 1, 1, 0, 5, 0, 0, 1, 3, 2
// ==UserScript==
// @name           MySpacePicenlarge++
// @namespace      MySpacePicenlarge++
// @description    As you scroll over small MySpace photos, this script displays the enlarged photo plus a ton of user information with it.
// @include        *.myspace.com/*
// ==/UserScript==

var maxImgHeight = 450;
var maxImgWidth = 450;

function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}

addGlobalStyle('#trailimageid {color: black !important; font-size: 10px !important; position: absolute; text-align: left !important; ' +
            'display: none; left:0px; top:0px; height: 0px; z-index: 2000 !important;} .searchImg {border: 1px solid #E0E0E0;}')

var allImages, thisImage, largeImage, largeImageHeight, myImage, theObj, thisLink, allLinks, description, thisDiv, allDivs, currentimageheight;
var friendStatus = '';
var globalTimer;

var circleIcon = document.createElement('img');
circleIcon.src = 'data:image/gif,GIF89a%16%00%15%00%A2%00%00%FF%FF%FF%F2%F2%F2%D7%E9%FA%E2%E2%E2%C6%DF%F8%CC%CC%CC%89' +
                '%B1%D9x%A1%CB!%FF%0BNETSCAPE2.0%03%01%00%00%00!%F9%04%05%0A%00%00%00%2C%00%00%00%00%16%00%15%00%00%' +
                '03R%08%BA%2Bw%82%C9%B9%8E1%87%CAPJP%16%A68%D0T%0CC1%3E%11%10f%D2%99j%EF%C4y%1A%D9j%BC%DD%7D%BD%06K%' +
                'A6%0A%82.%07%A2%F1%88%B9%01%8D%BA%A5t%BAp%1A%AD%00eP%AB%EDi%B1%3D0%03%2B%D6pQE%2FZ%D1%E5%91%7F%93%0' +
                '4%00!%F9%04%05%0A%00%00%00%2C%09%00%00%00%0C%00%11%00%00%03!%18U%01%FE%AE%8CQ%20%94%D4%3E%C5%B4%FF%' +
                '60(%8Edi%9E%8Fp%1C%C2w%18%C6%E1%C2%B2%A7%B2%09%00!%F9%04%05%0A%00%00%00%2C%0C%00%02%00%07%00%13%00%' +
                '00%03%20%08%1AU%A1%A0%8CQ%A0%A4%909%C8%BB%FF%60(%8E%A4B%1C%07%01%1D%86q%AC%EDk%A2%AA%92%00%00!%F9%0' +
                '4%05%0A%00%00%00%2C%06%00%07%00%10%00%0E%00%00%03%22%08%BA%ACQ%25%B4%09%CA%18%856%8B5%7B%91\'%8Edi%9' +
                'E%24q%1C%04y%18%C6%E1%C2%F2%A8%B2d%02%00!%F9%04%05%0A%00%00%00%2C%00%00%0D%00%15%00%04%00%00%03%1C%' +
                '08tG%F00%BEPJ%00%C7%98%23%3B(%C3P%60%1A%E7E%A0%A80%CE%09QV%02%00!%F9%04%05%0A%00%00%00%2C%00%00%07%' +
                '00%10%00%0E%00%00%03!Hw%04%FE%D0%1DcN%BC%60V%1C%15%E3%60(%8Edi%9EcP%14%C1X%0CC%E1%C2%B2%A8%B2%09%00' +
                '!%F9%04%05%0A%00%00%00%2C%03%00%02%00%07%00%13%00%00%03%1EHw%04~%C6%1C%07%A0%A4%8A%D1%CD%BB%FF%60(%' +
                '8E_P%14%01U%0CC%A1%B2%AEc%A2%09%00!%F9%04%05%0A%00%00%00%2C%00%00%00%00%0D%00%11%00%00%03%23%08%BA%' +
                '2Bw%82%C9c%CC%99%8BZ%C9%1C%E4%60(%8Edi%9E%A8%19%14E%20%16%C3P%BC%F1%1C%AEm%98%00%00!%F9%04%09%0A' +
                '%00%00%00%2C%00%00%00%00%16%00%15%00%00%03%2C%08%BA%DC%FE0J%26%CE%11%F3%1DcNv%5B%F75%D55NAQ%04%E' +
                '7R%0CC%D1*o%3C%03%E9z%EF%7C%EF%FF%C0%A0p%F8I%00%00%3B'	

var newDiv2 = document.createElement('div');
newDiv2.id = 'trailimageid';
document.body.appendChild(newDiv2);

var newPathHolderDiv = document.createElement('div');
newPathHolderDiv.style.display="none";
newPathHolderDiv.id = 'pathHolderDiv';
var html2 = "";
newPathHolderDiv.innerHTML = html2;
document.body.appendChild(newPathHolderDiv);

//this Div fills the entire screen and it's used for screen measurement
var fillDiv = document.createElement('div');
fillDiv.id = 'fillDiv';
fillDiv.style.visibility = "hidden";
//fillDiv.style.z-index = -1;
fillDiv.style.left = 0;
fillDiv.style.top = 0;
fillDiv.style.position = "fixed";
fillDiv.style.width = "100%";
fillDiv.style.height = "100%";
document.body.appendChild(fillDiv);


// window.addEventListener(
    // 'load',
    // function() { doThings(); },
    // true);
   
// on view more pics pages, this will remove the annoying titles
allLinks = document.evaluate(
    '//a[contains(@id, "UserViewPictureControl")]',
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null); 
for (var i = 0; i < allLinks.snapshotLength; i++) {
    thisLink = allLinks.snapshotItem(i);
    thisLink.title = '';
}
// removes the new friend helper on the new friend list.
allDivs = document.evaluate(
    '//div[contains(@onmouseover, "friendHelper")]',
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);	
for (var i = 0; i < allDivs.snapshotLength; i++) {
    thisDiv = allDivs.snapshotItem(i);
    thisDiv.removeAttribute('onmouseover');
    thisDiv.removeAttribute('onmouseout');
}

//we gather up all images here
allImages = document.evaluate(
    '//img[contains(@src, "ac-images")]',
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null); 
 
for (var i = 0; i < allImages.snapshotLength; i++) {
    thisImage = allImages.snapshotItem(i);
    var src = thisImage.src;
    smallImage = thisImage.src;
    thisImage.id = "searchImg";
    thisImage.alt = "t" + i;
    
	if (thisImage.parentNode.href) {
	    var parentHref = thisImage.parentNode.href.toLowerCase();
	    var friendID = parentHref.substring(parentHref.indexOf('friendid=') + 9);
	    if (friendID.indexOf(friendID.match(/\D/)) > 0) {
	        friendID = friendID.substring(0, friendID.indexOf(friendID.match(/\D/)));
	    }
	}
	thisImage.title = "";
    //store all image sources in the hidden Div
    html2 = html2 + '\nLIt' + i + " " + getLargeSrc(thisImage.src) + '<br>';
    html2 = html2 + '\nFIt' + i + " " + friendID + '<br>';
    newPathHolderDiv.innerHTML = html2 + '\n';
 
    // set the mouseover and mouseout event listeners
    thisImage.addEventListener(
        'mouseover',
        function(event) {
            var imgID = this.alt;
			document.getElementById("trailimageid").innerHTML = "";
			document.getElementById("trailimageid").style.visibility = "visible";
			globalTimer = window.setTimeout(function() { showtrail(imgID,this,friendID);}, 250);			
        },
        true);
 
    thisImage.addEventListener(
        'mouseout',
        function(event) {
			window.clearTimeout(globalTimer);
			document.getElementById("trailimageid").style.visibility = "hidden";
			description = "";
            window.setTimeout(function() { hidetrail(); }, true);
        },
        true);
	//imgID = this.alt;
	//window.setTimeout(function() { getDetail(imgID,this); }, 0);
}

function getLargeSrc(imgSrc){
    largeImage = imgSrc.replace("_m.jpg","_l.jpg");
    largeImage = largeImage.replace("/m_","/l_");
    largeImage = largeImage.replace("_s.jpg","_l.jpg");
    largeImage = largeImage.replace("/s_","/l_");
 
    return largeImage;
}

var friendInfo = ""
friendInfo = document.getElementById("pathHolderDiv").innerHTML;
theObj="";

//lets get the source from our storrage.
function getImgSrc(imgID){
	imgSrc = friendInfo.substring(friendInfo.indexOf("LI" + imgID) + ("LI" + imgID).length + 1,friendInfo.indexOf("<br>",friendInfo.indexOf("LI" + imgID)));
	return imgSrc;
}

function getFriendID(imgID){
	friendID = friendInfo.substring(friendInfo.indexOf("FI" + imgID) + ("FI" + imgID).length + 1,friendInfo.indexOf("<br>",friendInfo.indexOf("FI" + imgID)));
	return friendID;
}
theObj="";
function showtrail(imgID,me){
	friendStatus = '';
	getFriendship(imgID);
	friendID = getFriendID(imgID)
    imgSrc = getImgSrc(imgID);
    newLargeImage = new Image();
    newLargeImage.src = getImgSrc(imgID);
	waitFor(newLargeImage);
    getDetail(imgID,me,friendID);
}

function waitFor(img){
	currentimageheight = '';
    currentimagewidth = '';
    if(!img.complete){
        imgWait=window.setTimeout(function(){waitFor(img);}, 50);
    }
    else{
        height = newLargeImage.height;
        width = newLargeImage.width;
        if (height > maxImgHeight) {
            width = width * (maxImgHeight / height);
            height = maxImgHeight;
        }
        if (width > maxImgWidth) {
            height = height * (maxImgWidth / width);
            width = maxImgWidth;
        }
		if (height < 300){
			height = 300;
		}
    currentimageheight = height;
    currentimagewidth = width;
    }
}

//this function will get friendship status
//friendStatus = '';
function getFriendship(imgID){
var html;
html = '';
GM_xmlhttpRequest({
            method: 'GET',
            url: 'http://comment.myspace.com/index.cfm?fuseaction=user.viewProfile_commentForm&friendID=' + getFriendID(imgID),
            headers: {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8'},
            onload: function(responseDetails) {
				friendStatus = '';
                var html = responseDetails.responseText.replace(/\t|\r|\n/g,'');
				if (html.indexOf('friend to make comments about them') > 0){
					friendStatus = '<font color="green">is NOT a friend</font>';
				}
				else {
					friendStatus = '<font color="red">is a friend</font>';
				}
			},
		})
//return friendStatus;
//friendID = "";
}
						
function getDetail(imgID,me,friendID){
	//friendID = getFriendID(imgID);
	description = '';
	newHTML = '';
	newHTML = '<div style="padding: 5px; border:0px;">';
	newHTML = newHTML + '<div align="center" style="padding: 2px 2px 2px 2px;">';
	newHTML = newHTML + '<img src="' + circleIcon.src + '" border="0"></div>';
	newHTML = newHTML + '</div>';
	document.getElementById("trailimageid").innerHTML = newHTML;
	document.getElementById("trailimageid").style.display="inline";
    var fiInfo = document.getElementById("pathHolderDiv").innerHTML;
    if (fiInfo.indexOf('<fi' + friendID + '>') > 0) {  
        description = fiInfo.substring(fiInfo.indexOf('<fi' + friendID + '>') + friendID.length + 4,fiInfo.indexOf('</fi', fiInfo.indexOf('<fi' + friendID + '>')));
        finalDiv(imgID,imgSrc,description,me,friendID,'');
    }
    else{
        theObj=me;
		window.setTimeout(function() {finalDiv(imgID,imgSrc,'',me,friendID,newHTML);},0);
        GM_xmlhttpRequest({
            method: 'GET',
            url: 'http://profile.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=' + friendID,
            headers: {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.8) Gecko/20071008 Firefox/2.0.0.8'},
            onload: function(responseDetails) {
                var html = responseDetails.responseText.replace(/\t|\r|\n/g,'');
                var str1 = '<td class="text" width="193" bgcolor="#ffffff" height="75" align="left">';
                var isOnline = '<br><img src="http://x.myspace.com/images/onlinenow.gif" id="ctl00_Main_ctl00_UserBasicInformation1_OLNClient_OnlineImage" alt="Is Online" class="ImgOnlineNow" /><br>';
                description = html.substring(html.indexOf("<br>", html.indexOf(str1)) + 12,html.indexOf("</td>",html.indexOf("<br>",
                                html.indexOf(str1)))).replace(/    /g,'').replace(/<br \/>/g,'<br>').replace(/<br><br><br><br>/g,
                                '<br>').replace('Last Login:', 'Last Login:<br />').replace(isOnline, '<font color="green">Is Online</font>');
                var name = "";
				var hasFriends = "";
				var hasComments = "";
				var status = "";
				var orientation = "";
				var hometown = "";
				var bodyType = "";
				var ethnicity = "";
				var religion = "";
				var zodiac = "";
				var drink = "";
				var children = "";
				var education = "";
				var occupation = "";
				var income = "";
				var friendStat = "";
				
				friendStat = getFriendship(imgID);
				
                if (html.indexOf('<span class="redbtext">') > 0){
                    friendCount = html.substring(html.indexOf('<span class="redbtext">') + 23, html.indexOf('</span>', html.indexOf('<span class="redbtext">')));
                    if (friendCount < 700 && friendCount > 30) {					
						hasFriends = '<hr color="#b2b4bf"><font color="green">' + friendCount + ' friends</font>';
					}else{
						hasFriends = '<hr color="#b2b4bf"><font color="red">' + friendCount + ' friends</font>';
					}
                    if (html.indexOf('f<span class="redtext">') > 0){						
						commentCount = html.substring(html.indexOf('f<span class="redtext">') + 24, html.indexOf(' </span>', html.indexOf('f<span class="redtext">')));
	                 	if (parseInt(friendCount) < parseInt(commentCount)) {
							hasComments = '<br><font color="green">' + commentCount + ' comments</font><hr color="#b2b4bf">';
						}else {
							hasComments = '<br><font color="red">' + commentCount + ' comments</font><hr color="#b2b4bf">';
						}
					}
					if (html.indexOf('ProfileStatus') > 0){
						status = html.substring(html.indexOf('>',html.indexOf('ProfileStatus')) + 1, html.indexOf('</td>', html.indexOf('ProfileStatus'))) + '<br>';
					}
					if (html.indexOf('ProfileOrientation') > 0){
						orientation = html.substring(html.indexOf('>',html.indexOf('ProfileOrientation')) + 1, html.indexOf('</td>', html.indexOf('ProfileOrientation'))) + '<br>';
					}
					if (html.indexOf('ProfileHometown') > 0){
						hometown = html.substring(html.indexOf('>',html.indexOf('ProfileHometown')) + 1, html.indexOf('</td>', html.indexOf('ProfileHometown'))) + '<br>';
					}
					if (html.indexOf('ProfileBody type') > 0){
						bodyType = html.substring(html.indexOf('>',html.indexOf('ProfileBody type')) + 1, html.indexOf('</td>', html.indexOf('ProfileBody type'))) + '<br>';
					}
					if (html.indexOf('ProfileEthnicity') > 0){
						ethnicity = html.substring(html.indexOf('>',html.indexOf('ProfileEthnicity')) + 1, html.indexOf('</td>', html.indexOf('ProfileEthnicity'))) + '<br>';
					}
					if (html.indexOf('ProfileReligion') > 0){
						religion = html.substring(html.indexOf('>',html.indexOf('ProfileReligion')) + 1, html.indexOf('</td>', html.indexOf('ProfileReligion'))) + '<br>';
					}
					if (html.indexOf('ProfileZodiac') > 0){
						zodiac = html.substring(html.indexOf('>',html.indexOf('ProfileZodiac')) + 1, html.indexOf('</td>', html.indexOf('ProfileZodiac')));
						zodiac = zodiac.replace(zodiac.substring(zodiac.indexOf('<a href='),zodiac.indexOf('>',zodiac.indexOf('<a href=')) + 1),'').replace('</a>','') + '<br>';
					}
					if (html.indexOf('ProfileSmoke') > 0){
						drink = html.substring(html.indexOf('>',html.indexOf('ProfileSmoke')) + 1, html.indexOf('</td>', html.indexOf('ProfileSmoke'))) + '<br>';
					}
					if (html.indexOf('ProfileChildren') > 0){
						children = html.substring(html.indexOf('>',html.indexOf('ProfileChildren')) + 1, html.indexOf('</td>', html.indexOf('ProfileChildren'))) + '<br>';
					}
					if (html.indexOf('ProfileEducation') > 0){
						education = html.substring(html.indexOf('>',html.indexOf('ProfileEducation')) + 1, html.indexOf('</td>', html.indexOf('ProfileEducation'))) + '<br>';
					}
					if (html.indexOf('ProfileOccupation') > 0){
						occupation = html.substring(html.indexOf('>',html.indexOf('ProfileOccupation')) + 1, html.indexOf('</td>', html.indexOf('ProfileOccupation'))) + '<br>';
					}
					if (html.indexOf('ProfileIncome') > 0){
						income = html.substring(html.indexOf('>',html.indexOf('ProfileIncome')) + 1, html.indexOf('</td>', html.indexOf('ProfileIncome'))) + '<br>';
					}
                }
                name = html.substring(html.indexOf('class="nametext">') + 17, html.indexOf('</span>',html.indexOf('class="nametext">')));
				description = '<font style="color:black;" color="black">' + name + '<hr color="#b2b4bf">' + description + hasFriends + hasComments + status + orientation + hometown + bodyType + ethnicity + religion + zodiac + 
								drink + children + education + occupation + income + '<hr color="#b2b4bf">' + friendStatus + '</font>';
                window.setTimeout(function() {finalDiv(imgID,imgSrc,description,me,friendID,'');},0);
                newPathHolderDiv.innerHTML = newPathHolderDiv.innerHTML + '<FI' + friendID + '>' + description + '</FI' + friendID + '>\n';
                //GM_log(html2)
				friendID = "";
            },
        });
    }
}

function finalDiv(imgID,imgSrc,description,me,friendID,newHTML2){
	//friendID = getFriendID(imgID);
    newHTML = '<div style="color: black !important; padding: 5px; background-color: #FFF; border: 2px solid #6698cb;">';
    newHTML = newHTML + '<table border="0" cellpadding="0" cellspacing="0">';
    newHTML = newHTML + '<tr><td width="120" style="padding-right:4px;" valign="top"><b><font style="color:black !important; font-size:10px !important">' + newHTML2 + description + '</font></b><br><img height="1" width="120" src="http://x.myspace.com/images/spacer.gif"></td>';
    newHTML = newHTML + '<td valign="top"><div align="center" style="padding: 2px 2px 2px 2px;">';
    newHTML = newHTML + '<img style="min-height:300px; border:1px solid #6698cb; max-height:' + maxImgHeight + 'px; max-width:' + maxImgWidth + 'px;" src="' + imgSrc + '" border="0"></div>';
    newHTML = newHTML + '</td></tr></table></div>';
    //GM_log(newHTML);
    document.getElementById("trailimageid").innerHTML = newHTML;
    document.getElementById("trailimageid").style.display="inline";
	theObj=me;
    theObj.onmousemove=followmouse;
}

function hidetrail(){
	//document.onmousemove="";
    document.getElementById("trailimageid").style.innerHTML = " ";
    document.getElementById("trailimageid").style.display="none";
    document.getElementById("trailimageid").left="-500px";
	document.getElementById("trailimageid").innerHTML = "";
	description = "";
}

//from here on, we create the mouse over effect.
function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function followmouse(){
    var e=arguments[0]?arguments[0]:event;
    var xcoord=15
    var ycoord=15
    var plusFactor = 35
    var scrollerWidth = ((window.outerWidth - window.innerWidth));
    currentimagewidth = document.getElementById("trailimageid").scrollWidth + 7; 
	var div = document.getElementById("fillDiv");
	var docwidth= div.scrollWidth;
	var docheight= div.scrollHeight;
 
    if (typeof e != "undefined"){
        if ((docwidth - scrollerWidth) - e.pageX < currentimagewidth){
            xcoord = e.pageX - xcoord - (currentimagewidth); // Move to the left side of the cursor
        } else {
            xcoord += e.pageX;
        }
        if (docheight - e.pageY < (currentimageheight + plusFactor)){
            ycoord += e.pageY - Math.max(0,(plusFactor + currentimageheight + e.pageY - docheight - truebody().scrollTop));
        } else {
            ycoord += e.pageY;
        }
    } 
    if(ycoord < 0) { ycoord = ycoord*-1; }
    document.getElementById("trailimageid").style.left=xcoord+"px"
    document.getElementById("trailimageid").style.top=ycoord+"px"
}