PMOG Association Spy

By David Severwright Last update Dec 20, 2008 — Installed 94 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

There are 2 previous versions of this script.

// ==UserScript==
// @name           PMOG Association Spy
// @namespace      davidsev
// @description    Shows peoples second and third assocations on there profiles.
// @include        http*://pmog.com/users/*
// @include        http*://*.pmog.com/users/*
// @exclude        http*://pmog.com/users/*/*
// @exclude        http*://*.pmog.com/users/*/*
// ==/UserScript==

// This code is copyright David Severwright 2008.
// You can do what you want with this, just credit me etc.

var leftBar = document.getElementsByClassName("user_profile_left")[0]

if (!leftBar)
	return;

GM_xmlhttpRequest({
	method:"GET",
	url:window.location + ".json",
	onload:function(details)
	{
		if (details.status == 200)
		{
			var details = eval('(' + details.responseText + ')'); // JSON.parse(details.responseText);
			var images = leftBar.getElementsByTagName('img');
			for (i = 0; i < images.length; i++)
			{
				if (/\/images\/shared\/associations\/icon/.test(images[i].src))
				{
					var assoc = images[i].alt.toLowerCase();
					var span = document.createElement("span");
					span.style.fontFamily = "mono";
					images[i].parentNode.insertBefore(span, images[i]);
					if (assoc == details.primary_association.toLowerCase() + "s")
					{
						//images[i].parentNode.insertBefore(document.createTextNode("1 "), images[i]);
						span.appendChild(document.createTextNode("1 "));
					}
					else if (assoc == details.secondary_association.toLowerCase() + "s")
					{
						span.appendChild(document.createTextNode("2 "));
					}
					else if (assoc == details.tertiary_association.toLowerCase() + "s")
					{
						span.appendChild(document.createTextNode("3 "));
					}
					else
					{
						span.appendChild(document.createTextNode("- "));
					}
				}
			}
		}
	}
});