There are 59 previous versions of this script.
Add Syntax Highlighting (this will take a few seconds, probably freezing your browser while it works)
// ==UserScript==
// @name LJ Profile Reset
// @namespace http://axisofevil.net
// @description Resets the LJ user profile.
// @include http://*.livejournal.com/profile*
// @include http://*.livejournal.com/*/profile*
// @exclude http://*.livejournal.com/*/*/profile*
// @author the-xtina@livejournal.com
// ==/UserScript==
/*
This resets the userpage back to the best (imo) view. I am going based on
cached copies of several types of LJ profiles (via archive.org).
A few items are new, such as tags and membership type. I stuck them in where
they made the most sense. You can change the order of things, and remove things
from view, in the "Set this" section towards the bottom.
Please see the script's home page for updates:
http://userscripts.org/scripts/show/37286
*/
// If true, this will append the reformatted profile to the existing profile.
var debug = false;
/* *** */
/*
* First things first.
*/
/* These two vars deal with Virtual Gifts. */
// True = display as images, below the title/subtitle section.
// False (default)= display as a number, at the bottom of the page.
var ljvSwitch = false;
// The maximum number of virtual gift images you want to see, iff you're
// displaying images at all. 9 fits on a 1024x768 display nicely. Set to 0 if
// you want them all.
// WARNING: go to the news profile to see why that's a *terrible* idea.
var ljvCount = 9;
// In the future, I will have translation. In the meantime, see line ~184.
var langID = document.getElementById("footer_lang_list");
if (langID) { langID = langID.getElementsByTagName("option")[langID.selectedIndex].value; }
// This'll be the new profile-y table.
var ljTable = document.createElement("table");
ljTable.setAttribute("border", "0");
ljTable.setAttribute("width", "100%");
ljTable.setAttribute("cellpadding", "5");
ljTable.setAttribute("cellspacing", "-1");
// What kind of profile: community, syndicated, or user?
// Also get the username, and whether it's a full profile.
var ljType = window.location.href;
if (ljType.indexOf("mode=full") == -1) {
var ljFull = false;
} else {
var ljFull = true;
}
var ljFoo = ljType.split(".")[0];
if (ljFoo == "http://community") {
var ljUsername = ljType.split("/")[3];
ljType = "C";
} else if (ljFoo == "http://syndicated") {
var ljUsername = ljType.split("/")[3];
ljType = "S";
} else if (ljFoo == "http://users") {
var ljUsername = ljType.split("/")[3];
ljType = "U";
} else {
var ljUsername = ljFoo.split("//")[1];
if (ljUsername == "news") { ljType = "N"; } else { ljType = "U"; }
}
ljUsername = ljUsername.replace(/-/g, "_");
/* ***** */
/*
* The top bar stuff.
*/
// The userpic block. Thank gord it's always the same and always present.
var ljUserpic = getElementsByClassName(document, "div", "userpicdiv")[0].innerHTML;
// A note:
// - ljUsername is the actual LJ username.
// - ljUser is the username code, with lj-user icon and bolding and cetera.
// - ljName is the name the user sets for themself.
var ljUser = getElementsByClassName(document, "div", "username")[0].innerHTML;
// User notes?
var tmp = ljUser.indexOf("<span class=\"useralias-value\">*</span>");
var ljNote = "0";
if (tmp > -1) {
ljUser = ljUser.substr(0, tmp + 42);
var ljNote = "1";
}
// Title and subtitle, for non-feeds only.
var ljTitleblock;
if (ljType != "S") {
var ljTitle = getElementsByClassName(document, "p", "journal_title")[0];
if (ljTitle) { ljTitle = '<b>' + ljTitle.innerHTML + '</b>'; }
var ljSubtitle = getElementsByClassName(document, "p", "journal_subtitle")[0];
if (ljSubtitle != null) { ljSubtitle = '<i>' + ljSubtitle.innerHTML + '</i>'; }
if (ljTitle != null && ljSubtitle != null) {
ljTitleblock = "<br /><div style='font-size:12pt;'>" + ljTitle + "<br />" + ljSubtitle + "</div><br />";
} else if (ljTitle != null && ljSubtitle == null) {
ljTitleblock = "<br /><div style='font-size:12pt;'>" + ljTitle + "</div><br />";
} else if (ljTitle == null && ljSubtitle != null) {
ljTitleblock = "<br /><div style='font-size:12pt;'>" + ljSubitle + "</div><br />";
}
}
// The details_stats chunk.
var ljDetails = getElementsByClassName(document, "div", "details_stats")[0].childNodes;
for (var x = 0; x < ljDetails.length; x++) {
var tmpThing = ljDetails[x].innerHTML;
// User number, created/joined, last updated. All on one line.
if (tmpThing.indexOf(" (#") > -1) {
var tmpArray = tmpThing.split(",")[0].split(" ");
ljUser += ' ' + tmpArray.pop();
var ljCreated = tmpArray.pop();
ljCreated += ' ' + tmpArray.pop();
var ljCreated_Title = tmpArray.join(" ");
if (ljDetails[x].childNodes.length == 1) {
var ljUpdated = "Never updated";
} else {
var ljUpdated = ljDetails[x].childNodes[1].childNodes[0].nodeValue;
ljUpdated += ', <em>' + ljDetails[x].childNodes[1].getAttribute("title") + '</em>';
// Nudge.
var ljNudge;
if (ljDetails[x].childNodes.length == 5) {
ljNudge = '<a href="http://www.livejournal.com/friends/nudge.bml?user=' + ljUsername + '">';
ljNudge += '<img src="http://pics.livejournal.com/the_xtina/pic/0003azh0" style="border: 1px solid #99F; margin-bottom: 3px; vertical-align: middle;" alt="Nudge this user." title="Nudge this user."></a>';
}
}
var ljUpdated_Title = "Date updated:";
// Account type.
} else if (tmpThing.toLowerCase().indexOf("<strong") > -1) {
var ljAccountType = ljDetails[x].getElementsByTagName("strong")[0].innerHTML;
if (tmpThing.indexOf("paidstar") > -1) {
ljUser += ' <a href="http://www.livejournal.com/site/supporters.bml"><img src=http://www.livejournal.com/img/talk/md10_thumbup.gif style="vertical-align: middle;" border=0></a>';
}
var ljAccountType_Title = "Account Type"; // No :, that's set later.
// Adult concepts, oh noes!
} else if (tmpThing.toLowerCase().indexOf("warning.gif") > -1) {
var ljAdult = '<p>' + tmpThing + '</p>';
// Oh lord. Comments and support points.
} else {
var ljComments_Title = "Comments:";
var tmpArray = tmpThing.split(", ");
var ljComments = "";
for (var y = 0; y < tmpArray.length; y++) {
switch(y) {
case 0:
ljComments += '<b>Received:</b> ' + tmpArray[y].split(" ")[0]; break;
case 1:
ljComments = '<b>Posted:</b> ' + tmpArray[y].split(" ")[0] + ' - ' + ljComments; break;
case 2:
var ljSupport = tmpArray[y].split(" <a")[0];
var ljSupport_Title = '<a' + tmpArray[y].split(" <a")[1]; break;
}
}
}
}
// The links line.
tmpThing = getElementsByClassName(document, "div", "details_links")[0].childNodes[0].childNodes;
for (x = 1; x < tmpThing.length; x += 2) {
var tmpThing2 = tmpThing[x].getAttribute("href");
// Userpics count.
if (tmpThing2.indexOf("allpics.bml") > -1) {
var ljPic = tmpThing[x - 1].nodeValue;
if (ljPic.substring(0, 1) == ',') { ljPic = trim(Right(ljPic, ljPic.length - 1)); }
// Virtual gifts.
} else if (tmpThing2.indexOf("vgift.bml") > -1) {
var ljVgifts = tmpThing[x - 1].nodeValue;
if (ljVgifts.substring(0, 1) == ',') { ljVgifts = trim(Right(ljVgifts, ljVgifts.length - 1)); }
// This is for if images are displayed.
if (ljVgifts < ljvCount || ljvCount == 0) {
ljvCount = ljVgifts;
}
ljVgifts = '<a href="' + tmpThing2 + '">' + ljVgifts + '</a>';
var ljVgifts_Title = tmpThing[x].innerHTML;
// Memories.
} else if (tmpThing2.indexOf("memories.bml") > -1) {
var ljMemories = tmpThing[x - 1].nodeValue;
if (ljMemories.substring(0, 1) == ',') { ljMemories = trim(Right(ljMemories, ljMemories.length - 1)); }
ljMemories = '<a href="' + tmpThing2 + '">' + ljMemories + '</a>';
var ljMemories_Title = tmpThing[x].innerHTML;
// Scrapbook.
} else if (tmpThing2.indexOf("pics.livejournal") > -1) {
var ljPictures = tmpThing[x - 1].nodeValue;
if (ljPictures.substring(0, 1) == ',') { ljPictures = trim(Right(ljPictures, ljPictures.length - 1)); }
ljPictures = '<a href="' + tmpThing2 + '">' + ljPictures + '</a>';
var ljPictures_Title = tmpThing[x].innerHTML;
// Tags.
} else if (tmpThing2.indexOf("/tag/") > -1) {
var ljTags = tmpThing[x - 1].nodeValue;
if (ljTags.substring(0, 1) == ',') { ljTags = trim(Right(ljTags, ljTags.length - 1)); }
ljTags = '<a href="' + tmpThing2 + '">' + ljTags + '</a>';
var ljTags_Title = tmpThing[x].innerHTML;
// Entries.
} else {
var ljEntries = tmpThing[x - 1].nodeValue;
var ljEntries_Title = tmpThing[x].innerHTML;
}
}
// The action strip (add journal, track user, &c &c).
var ljActions = getElementsByClassName(document, "div", "actions")[0].childNodes[0].childNodes;
var ljActionstrip = " ";
for (x = 0; x < ljActions.length; x++) {
var tmp1 = ljActions[x].innerHTML;
if (tmp1.indexOf("-disabled.gif") == -1) {
var tmp2 = ljActions[x].getAttribute("title");
// Account for the note thing.
var tmp = 0;
if (tmp2.substr(0, 8) != "Add/edit") {
var tmp3 = "00";
} else {
if (tmp1.indexOf("Add Note") > -1) {
var tmp3 = "1" + ljNote;
} else {
var tmp3 = "2" + ljNote;
}
}
if (tmp3 == "00" || tmp3 == "10" || tmp3 == "21") {
ljActionstrip += tmp1.split(">")[0] + '>' + tmp1.split(">")[1].replace(/ alt=""/, "") + ' style="border: 1px solid #99F; margin-bottom: 3px; vertical-align: middle;" alt="' + tmp2 + '" title="' + tmp2 + '"></a>';
ljActionstrip += " ";
}
}
}
ljActionstrip = '<br /><span style="border: 1px solid #8FC3F7; background-color: #C5DFF9; padding: 5px;">' + ljActionstrip;
//Add the nudge button.
if (ljNudge) {
ljActionstrip += ljNudge;
}
ljActionstrip += '</span><br />';
/* ***** */
/*
* The Basic Info section.
*/
// Name, syndicated from, &c &c.
tmpThing = getElementsByClassName(document, "div", "userinfo");
if (tmpThing.length > 0) {
tmpThing = tmpThing[0].getElementsByTagName("tr");
var ljInfo = new Array();
var ljInfo_Title = new Array();
for (var x = 0; x < tmpThing.length; x++) {
ljInfo_Title.push(tmpThing[x].childNodes[0].innerHTML);
ljInfo.push(tmpThing[x].childNodes[1].innerHTML);
}
}
/* Interlude! After the above due to ljName. */
// Set the topmost row.
var tmpCell = document.createElement("td");
tmpCell.setAttribute("colspan", "3");
tmpCell.innerHTML = '<a href="http://userscripts.org/scripts/show/37286"><img src="http://pics.livejournal.com/the_xtina/pic/00039w7c" border=0 title="Go to LJ Profile Reset script page."></a> ';
if (ljType == "U" || ljType == "N") {
tmpCell.innerHTML += 'Below is user information for <b>' + ljUsername + '</b>. If you are this user, you can edit your information (or choose what information is considered public) at the <a href="http://www.livejournal.com/editinfo.bml">Edit Info page</a>.'
} else if (ljType == "C") {
tmpCell.innerHTML += 'Below is user information about the <b>' + ljUsername + '</b> community.';
if (ljActionstrip.indexOf("join.bml") > -1) {
tmpCell.innerHTML += ' To join this community, <a href="http://www.livejournal.com/community/join.bml?comm=' + ljUsername + '">click here</a>.';
} else {
tmpCell.innerHTML += ' You may <a href="http://www.livejournal.com/community/leave.bml?comm=' + ljUsername + '">leave the community</a> at any time.';
}
} else {
tmpCell.innerHTML += 'Below is information about the <b>' + ljUsername + '</b> feed.';
if (ljActionstrip.indexOf("Add this feed") > -1) {
tmpCell.innerHTML += ' If you would like articles from the syndicated site to appear on your friends page, you can <a href="http://www.livejournal.com/friends/add.bml?user=' + ljUsername + '">add this journal to your friends list</a>.';
}
}
var tmpRow = document.createElement("tr");
tmpRow.appendChild(tmpCell);
tmpRow.setAttribute("valign", "top");
ljTable.appendChild(tmpRow);
// Is there an adult warning? Add that too.
if (ljAdult) {
tmpCell = document.createElement("td");
tmpCell.setAttribute("colspan", "3");
tmpCell.innerHTML = ljAdult;
var tmpRow = document.createElement("tr");
tmpRow.appendChild(tmpCell);
tmpRow.setAttribute("valign", "top");
ljTable.appendChild(tmpRow);
}
// Add the actionstrip to the table.
if (ljActionstrip.length > 150) {
tmpCell = document.createElement("td");
tmpCell.setAttribute("colspan", "3");
tmpCell.setAttribute("align", "center");
tmpCell.innerHTML = ljActionstrip;
tmpRow = document.createElement("tr");
tmpRow.appendChild(tmpCell);
tmpRow.setAttribute("valign", "top");
ljTable.appendChild(tmpRow);
}
/* /interlude */
// All chat thingies blah blah users only. As they're product names,
// translation doesn't apply.
if (ljType == "U") {
tmpThing = getElementsByClassName(document, "td", "im_icon");
for (x = 0; x < tmpThing.length; x++) {
var tmpThing2 = tmpThing[x].childNodes[0].getAttribute("title");
if (tmpThing2 == null || tmpThing2 == '') { tmpThing2 = "LJ Talk"; }
switch(tmpThing2) {
case "LJ Talk":
var ljChatLJ = tmpThing[x].nextSibling.nextSibling.innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
ljChatLJ = Left(ljChatLJ, ljChatLJ.indexOf("<img") + 5) + ' border=0 ' + Right(ljChatLJ, ljChatLJ.length - (ljChatLJ.indexOf("<img") + 5));
break;
case "AIM":
var ljChatAIM = tmpThing[x].nextSibling.nextSibling.innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
break;
case "ICQ":
var ljChatICQ = tmpThing[x].innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
break;
case "Yahoo!":
var ljChatYahoo = tmpThing[x].nextSibling.nextSibling.innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
break;
case "MSN":
var ljChatMSN = tmpThing[x].innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
break;
case "Jabber":
var ljChatJabber = tmpThing[x].innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
break;
case "Google":
var ljChatGoogle = tmpThing[x].innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
break;
case "Skype":
var ljChatSkype = tmpThing[x].nextSibling.nextSibling.innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
break;
case "Gizmo Project":
var ljChatGizmo = tmpThing[x].innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
break;
case "Last.fm":
var ljChatLastFM = tmpThing[x].innerHTML + ' ' + tmpThing[x].nextSibling.innerHTML;
break;
}
}
}
// Contact block.
if (ljType == "U") {
var ljContact = getElementsByClassName(document, "div", "contact");
if (ljContact.length == 1) {
var ljContact_Title = ljContact[0].childNodes[0].innerHTML;
ljContact = ljContact[0].innerHTML.split("</p>")[1];
} else {
ljContact = undefined;
}
}
// Schools.
if (ljType == "U") {
tmpThing = getElementsByClassName(document, "div", "schools");
if (tmpThing.length > 0) {
tmpThing = tmpThing[0].childNodes;
var ljSchools = "";
for (x = 0; x < tmpThing.length; x++) {
if (tmpThing[x].tagName == "P") {
var ljSchools_Title = trim(tmpThing[x].childNodes[0].nodeValue);
if (Right(ljSchools_Title, 1) == ":") { ljSchools_Title = ljSchools_Title.substring(0, ljSchools_Title.length - 1); }
} else if (tmpThing[x].tagName == "SPAN") {
ljSchools += tmpThing[x].innerHTML;
if (x < tmpThing.length) { ljSchools += "<br />"; }
}
}
}
}
/* ***** */
/*
* Bio and interests. Together because why not.
*/
// Bio.
var ljBio = document.getElementById("bio_body");
if (ljBio) {
ljBio = ljBio.innerHTML;
var ljBio_Title = trim(document.getElementById("bio_header").childNodes[1].nodeValue);
}
// Interests.
if (ljType != "S") {
var tmpThing = document.getElementById("interests_body");
if (tmpThing) {
tmpThing2 = tmpThing.childNodes[0].innerHTML;
if (tmpThing2.indexOf("interests.bml") > -1) {
var ljInterests = "<b>" + tmpThing2.substring(tmpThing2.indexOf("(") + 1, tmpThing2.indexOf(")")) + ":</b> " + tmpThing.childNodes[1].innerHTML;
var ljInterests_Title = tmpThing.childNodes[0].innerHTML.split(" (")[0];
ljInterests_Title = '<a href="http://www.livejournal.com/interests.bml">' + ljInterests_Title + '</a>:<br />';
ljInterests_Title += "<small>[" + tmpThing.childNodes[0].innerHTML.split("[")[1];
if (tmpThing.childNodes[0].innerHTML.split("[").length == 3) {
ljInterests_Title += ' [' + tmpThing.childNodes[0].innerHTML.split("[")[2];
}
ljInterests_Title += '</small>';
ljInterests_Title = ljInterests_Title.replace(/> <span/i, "><br /><span");
}
}
}
/* ***** */
/*
* The friends/readers/maintainers/&c section.
*/
if (ljType == "U") {
//Friends...
var ljFriendsBlock = "<table border=0>";
var ljFriends_Title = trim(document.getElementById("friends_header").childNodes[1].nodeValue.split(" (")[0]);
if (Right(ljFriends_Title, 1) == ":") { ljFriends_Title = ljFriends_Title.substring(0, ljFriends_Title.length - 1); }
tmpThing = document.getElementById("friends_body");
if (tmpThing) {
var ljFriends = '<tr valign="top"><td nowrap>';
tmpThing = tmpThing.innerHTML;
if (tmpThing.indexOf("friendlist.bml") > -1) {
ljFriends += tmpThing;
} else {
tmpThing2 = tmpThing;
tmpThing = document.getElementById("friends_header").childNodes[1].nodeValue;
var ljFriends_Title = trim(Left(tmpThing, tmpThing.indexOf("(")));
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljFriends += '<img src="http://p-stat.livejournal.com/img/userinfo.gif" style="vertical-align: middle;"> <b>' + tmpThing + '</b>:</td><td>' + tmpThing2;
}
ljFriends += '</td></tr>';
} else {
ljFriends = "0 " + Left(ljFriends_Title, 1).toLowerCase() + Right(ljFriends_Title, ljFriends_Title.length - 1);
}
// Communities: watching goes in Friends, member is its own, same with posting access.
if (ljFriends.indexOf("friendlist.bml") == -1) {
tmpThing = document.getElementById("watching_body");
if (tmpThing) {
tmpThing = tmpThing.innerHTML;
if (Left(tmpThing, 9) != "This user") {
var ljWatching = tmpThing;
tmpThing = document.getElementById("watching_header").innerHTML;
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljWatching = '<tr valign="top"><td nowrap><img src="http://p-stat.livejournal.com/img/community.gif" style="vertical-align: middle;"> <b>' + tmpThing + '</b>:</td><td>' + ljWatching;
}
}
}
// Member of...
tmpThing = document.getElementById("mofs_body");
if (tmpThing) {
tmpThing = tmpThing.innerHTML;
var ljMemberOf = tmpThing;
tmpThing = document.getElementById("mofs_header").childNodes[1].nodeValue;
var ljMemberOf_Title = trim(Left(tmpThing, tmpThing.indexOf("(")));
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljMemberOf = '<b>' + tmpThing + '</b>: ' + ljMemberOf;
}
// Where can I, the user, post to?
tmpThing = document.getElementById("posting_body");
if (tmpThing) {
tmpThing = tmpThing.innerHTML;
var ljPosting = tmpThing;
tmpThing = document.getElementById("posting_header").childNodes[1].nodeValue;
var ljPosting_Title = trim(Left(tmpThing, tmpThing.indexOf("(")));
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljPosting = '<b>' + tmpThing + '</b>: ' + ljPosting;
}
// Mutual...
tmpThing = document.getElementById("mutual_body");
if (tmpThing) {
tmpThing = tmpThing.innerHTML;
var ljMutual = tmpThing;
tmpThing = document.getElementById("mutual_header").childNodes[1].nodeValue;
var ljMutual_Title = trim(Left(tmpThing, tmpThing.indexOf("(")));
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljMutual = "<b>" + tmpThing + "</b>: " + ljMutual;
}
// Also friend of...
tmpThing = document.getElementById("fofs_body");
if (tmpThing) {
tmpThing = tmpThing.innerHTML;
var ljFriendOf = tmpThing;
tmpThing = document.getElementById("fofs_header").childNodes[1].nodeValue;
var ljFriendOf_Title = trim(Left(tmpThing, tmpThing.indexOf("(")));
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljFriendOf = "<b>" + tmpThing + "</b>: " + ljFriendOf;
}
// Feeds...
if (ljFriends.indexOf("friendlist.bml") == -1) {
tmpThing = document.getElementById("watchingfeeds_body");
if (tmpThing) {
tmpThing = tmpThing.innerHTML;
if (Left(tmpThing, 9) != "This user") {
var ljFeeds = tmpThing;
tmpThing = document.getElementById("watchingfeeds_header").innerHTML;
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljFeeds = '<tr valign="top"><td nowrap><img src="http://p-stat.livejournal.com/img/syndicated.gif" style="vertical-align: middle;"> <b>' + tmpThing + '</b>:</td><td>' + ljFeeds;
}
}
}
// Friendsblock.
ljFriendsBlock = ljFriendsBlock + ljFriends;
if (ljWatching) { ljFriendsBlock = ljFriendsBlock + ljWatching; }
if (ljFeeds) { ljFriendsBlock = ljFriendsBlock + ljFeeds; }
} else if (ljType == "C") {
// Maintainers.
tmpThing = document.getElementById("maints_body");
if (tmpThing) {
tmpThing = tmpThing.innerHTML;
var ljMaintainers = tmpThing;
tmpThing = document.getElementById("maints_header").innerHTML;
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljMaintainers = "<b>" + tmpThing + "</b>: " + ljMaintainers;
}
// Members.
tmpThing = document.getElementById("members_body");
if (tmpThing) {
tmpThing = tmpThing.innerHTML;
if (tmpThing.indexOf("View all") > -1) {
var ljMembers = '<a href="http://www.livejournal.com/directory.bml?s_fro=1&fro_user=' + ljUsername + '">View all</a>';
} else {
var ljMembers = tmpThing;
}
tmpThing = document.getElementById("members_header").innerHTML;
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljMembers = "<b>" + tmpThing + "</b>: " + ljMembers;
}
// Watched by.
tmpThing = document.getElementById("fofs_body");
if (tmpThing) {
tmpThing = tmpThing.innerHTML;
var ljWatchedBy = tmpThing;
tmpThing = document.getElementById("fofs_header").innerHTML;
tmpThing = tmpThing.substring(tmpThing.indexOf("(") + 1, tmpThing.indexOf(")"));
ljWatchedBy = "<b>" + tmpThing + "</b>: " + ljWatchedBy;
}
}
/* ***** */
/*
* Set things. To never see an item on a profile (e.g., "Gizmo5 Project"),
* just comment out the appropriate line(s) below. I tried to be clear with
* variable names, so as to make it easier on yall.
*/
// Always "User", because (a) there's no instance of just-'user' on the page,
// and (b) heck with it.
setTable(ljUser, "User:");
if (ljTitleblock) { setTable(ljTitleblock, " "); }
if (ljvSwitch == true) {
if (ljvCount > 0) {
// Set the table with an ID'd cell for later.
setTable("vg", '<a href="http://www.livejournal.com/manage/vgift.bml?u=' + ljUsername + '">' + ljVgifts_Title + '</a>:');
}
}
if (ljInfo) {
for (x = 0; x < ljInfo.length; x++) {
setTable(ljInfo[x], ljInfo_Title[x]);
}
}
if (ljType == "U") { if(ljContact) { setTable(ljContact, ljContact_Title); } }
if (ljChatLJ) { setTable(ljChatLJ, "LJ Talk:"); }
if (ljChatAIM) { setTable(ljChatAIM, "AOL IM:"); }
if (ljChatICQ) { setTable(ljChatICQ, "ICQ:"); }
if (ljChatYahoo) { setTable(ljChatYahoo, "Yahoo!:"); }
if (ljChatMSN) { setTable(ljChatMSN, "MSN:"); }
if (ljChatJabber) { setTable(ljChatJabber, "Jabber:"); }
if (ljChatGoogle) { setTable(ljChatGoogle, "Google Talk:"); }
if (ljChatSkype) { setTable(ljChatSkype, "Skype:"); }
if (ljChatGizmo) { setTable(ljChatGizmo, "Gizmo5:"); }
if (ljChatLastFM) { setTable(ljChatLastFM, "Last.fm:"); }
if (ljBio) { setTable(ljBio, ljBio_Title); }
if (ljSupport) { setTable(ljSupport, '<a href="http://www.livejournal.com/support/">' + ljSupport_Title + '</a>:'); }
if (ljMemories) { setTable(ljMemories, ljMemories_Title); }
if (ljPictures) { setTable(ljPictures, ljPictures_Title); }
if (ljTags) { setTable(ljTags, ljTags_Title); }
if (ljInterests) { setTable(ljInterests, ljInterests_Title); }
if (ljType == "U") {
if (ljSchools) { setTable(ljSchools, '<a href="http://www.livejournal.com/schools/">' + ljSchools_Title + '</a>:'); }
}
if (ljType == "U" || ljType == "N") {
if (ljFriendsBlock) { setTable(ljFriendsBlock, '<a href="http://www.livejournal.com/users/' + ljUsername + '/friends">' + ljFriends_Title + '</a>:'); }
if (ljMutual) { setTable(ljMutual, ljMutual_Title); }
if (ljFriendOf) { setTable(ljFriendOf, ljFriendOf_Title); }
if (ljMemberOf) { setTable(ljMemberOf, ljMemberOf_Title); }
} else if (ljType == "C") {
if (ljMaintainers) { setTable(ljMaintainers, 'Maintainers:'); }
if (ljMembers) { setTable(ljMembers, '<a href="http://community.livejournal.com/' + ljUsername + '/friends">Members</a>:'); }
if (ljWatchedBy) { setTable(ljWatchedBy, 'Watched By:'); }
}
if (ljType != "S" && ljType != 'N') {
setTable(ljAccountType, '<a href="http://www.livejournal.com/support/faqbrowse.bml?faqid=38">' + ljAccountType_Title + '</a>:');
}
// Older profiles hid all this behind mode=full.
if (ljFull == true) {
setTable(ljCreated, ljCreated_Title);
setTable(ljUpdated, ljUpdated_Title);
setTable(ljEntries, ljEntries_Title);
setTable(ljComments, ljComments_Title);
}
if (ljPosting) { setTable(ljPosting, ljPosting_Title); }
if (ljvSwitch == false) {
if (ljVgifts) { setTable(ljVgifts, ljVgifts_Title); }
}
if (ljFull == false) {
tmpCell = document.createElement("td");
tmpCell.setAttribute("colspan", "3");
tmpCell.setAttribute("align", "center");
tmpCell.innerHTML = '<i><a href="' + window.location.href + '?mode=full">(more details...)</a></i>';
tmpRow = document.createElement("tr");
tmpRow.appendChild(tmpCell);
tmpRow.setAttribute("valign", "top");
ljTable.appendChild(tmpRow);
}
/* ***** */
/*
* Remove and print!
*/
tmpThing = document.getElementById("profile_page");
if (debug) {
tmpThing.appendChild(ljTable);
} else {
tmpThing.parentNode.replaceChild(ljTable, tmpThing);
}
// This comes after the table is created because we need to get the Vgift ID.
if (ljvSwitch == true && ljvCount > 0) {
var ljvUrl = "http://www.livejournal.com/manage/vgift.bml?u=" + ljUsername;
GM_xmlhttpRequest({
method: 'GET',
url: ljvUrl,
onload: function(responseDetails) {
var foo = responseDetails.responseText;
var ljvBeg = foo.indexOf("<div style='float:");
var ljvEnd = foo.indexOf("</div></div>\n\n\n");
var tmp = foo.substring(ljvBeg, ljvEnd).split("<p></p>");
for (var x = 0; x < ljvCount; x++) {
var tmp1 = tmp[x].substring(tmp[x].indexOf("<a"), tmp[x].indexOf("</a>")) + "</a>";
tmp1 = Left(tmp1, tmp1.indexOf("amp;")) + Right(tmp1, tmp1.length - (tmp1.indexOf("amp;") + 4));
document.getElementById("vgifts").innerHTML += tmp1;
if (x < ljvCount) {
document.getElementById("vgifts").innerHTML += " ";
}
}
}
});
}
/* ***** */
/*
* The functions.
*/
// Setting row elements for the new table.
function setTable(ljTd, ljTh) {
var tmpCell = document.createElement("th");
if (Right(ljTh, 1) != ':' && ljTh.length > 2 && Right(ljTh, 4) != "</a>" && Right(ljTh, 8) != "</small>") {
ljTh += ':';
}
ljTh = Left(ljTh, 1).toUpperCase() + Right(ljTh, ljTh.length - 1);
tmpCell.innerHTML = ljTh;
tmpCell.setAttribute("align", "right");
tmpCell.style.whiteSpace = "nowrap";
tmpCell.setAttribute("width", "1");
var tmpRow = document.createElement("tr");
tmpRow.appendChild(tmpCell);
tmpRow.setAttribute("valign", "top");
tmpCell = document.createElement("td");
// Vgiftage.
if (ljTd == "vg") {
tmpCell.setAttribute("id", "vgifts");
} else {
tmpCell.innerHTML = ljTd;
}
// Add the userpic.
if (ljTh == "User:") {
tmpRow.appendChild(tmpCell);
tmpCell = document.createElement("td");
tmpCell.innerHTML = ljUserpic;
tmpCell.setAttribute("align", "center");
tmpCell.setAttribute("width", "100");
tmpCell.setAttribute("rowspan", "6");
tmpRow.appendChild(tmpCell);
} else {
tmpCell.setAttribute("colspan", "2");
}
tmpRow.appendChild(tmpCell);
ljTable.appendChild(tmpRow);
}
// Code from: http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
function getElementsByClassName(oElm, strTagName, strClassName){
var arrElements = (strTagName == "*" && oElm.all)? oElm.all :
oElm.getElementsByTagName(strTagName);
var arrReturnElements = new Array();
strClassName = strClassName.replace(/\-/g, "\\-");
var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
var oElement;
for(var i=0; i<arrElements.length; i++){
oElement = arrElements[i];
if(oRegExp.test(oElement.className)){
arrReturnElements.push(oElement);
}
}
return (arrReturnElements)
}
// Code from: http://www.expertsforge.com/Web-Development/Tutorial-217.asp
function Left(str, n) {
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else
return String(str).substring(0,n);
}
// Code from: http://www.expertsforge.com/Web-Development/Tutorial-218.asp
function Right(str, n) {
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else
{
var iLen = String(str).length;
return String(str).substring(iLen, iLen - n);
}
}
// Code from: http://snipplr.com/view.php?codeview&id=8329
function trim(str) {
while('' + str.charAt(0) == ' ') {
str = str.substring(1, str.length);
}
while('' + str.charAt(str.length-1)==' ') {
str = str.substring(0, str.length-1);
}
return str;
}
