WoTStatScript - Forums

Adds a part of the signature from WoTLabs underneath the posterbox info for every post in a thread in the World of Tanks forums.

Od 05.12.2014.. Pogledajte najnovija verzija.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        WoTStatScript - Forums
// @version     0.932
// @description Adds a part of the signature from WoTLabs underneath the posterbox info for every post in a thread in the World of Tanks forums.
// @author      Orrie
// @namespace   http://forum.worldoftanks.eu/index.php?/topic/263423-
// @icon        http://dl.dropboxusercontent.com/u/12497046/wot/projects/statscript/img/icon.png
// @include     /^http://forum\.worldoftanks\.(eu|com|ru|asia|kr)/\S+/topic//
// @include     /^http://forum\.worldoftanks\.(eu|com|ru|asia|kr)/\S+\?showtopic/
// @include     /^http://forum.worldoftanks\.(eu|com|ru|asia|kr)/index\.php\?app=members&module=messaging&section=view&do=showConversation&topicID=\d+/
// @grant       none
// ==/UserScript==
(function () {
// data uri
var uri = {
	icon_arrow:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPwAAAAJCAMAAAAhKrH/AAAAV1BMVEUAAAD///+TKCf9AQmTLiX9AQmTMir9AQmTLif9AQmTMSz9AQmTMir9AQmTMyn9AQmTMirvGgKTMirsIAGTMirwGQOTMiqTMirsIAGaNDGgNzfqJwDrJABtE0DNAAAAGnRSTlMAABERIiIzM0REVVVmZnd3iIqZmrvDzN3g7thzQuwAAACHSURBVHja5dVLDsIwDEXRCySlP0IMoXXs7H+dDBASA1bQ3B0cPclm2Fe2wrfTQeO3qwqqAKWek80HxfO/l1/EBRgtU2tf+KkJ7TO9hdVSV3jU42f6ZClY6Qt/d4n+BGol29jTwQN1pE2QbA610BVefImuwL7xsNAXXhVpEYY8kNfO/rwsyA3ekEsOT2YDLE8AAAAASUVORK5CYII="
};

// style contents
var style = elem("style", "wotstatscript", "", "text/css");
	style.innerHTML = ".author_info {z-index: 1;}"
					+ ".user_details > br {display: none;}"
					+ ".basic_info {margin: 0 0 4px;}"
					+ ".user_stats {margin: 5px 0; width: 106px;}"
					+ ".user_stats td {padding: 0 0 2px; font-weight: bold;}"
					+ ".user_stats td a { background: url("+uri.icon_arrow+") no-repeat scroll 0 2px rgba(0, 0, 0, 0); padding: 0 0 0 10px; vertical-align: middle;}"
					+ ".user_stats td a:hover {background: url("+uri.icon_arrow+") no-repeat scroll -244px 2px rgba(0, 0, 0, 0);}"
					+ "";
	document.head.appendChild(style);
// end style

// get server info
var srv = { srv: document.location.host.match(/\.([^\.]+)$/)[1], wl: false, nm: false, ws: false, wr: false, wlife: false};
switch(srv.srv) {
	case ("eu"):
		srv.wl = srv.nm = srv.ws = srv.wr = srv.wlife = srv.srv;
		break;
	case ("ru"):
		srv.wl = srv.nm = srv.ws = srv.wr = srv.srv;
		break;
	case ("com"):
		srv.wl = srv.nm = srv.ws =  "na"; srv.wr = "com";
		break;
	case ("asia"):
		srv.wl = srv.nm = srv.ws = "sea"; srv.wr = "com";
		break;
	case ("kr"):
		srv.wl = srv.nm = srv.ws = srv.srv; srv.wr = "com";
		break;
	default: break;
}

// looping for every post
var post_block = document.getElementsByClassName('post_block');
for (var i=0; i<post_block.length; i++) {
	var author_hcid = post_block[i].getElementsByClassName('ipsUserPhotoLink')[0].getAttribute("hovercard-id"),
		author_info = post_block[i].getElementsByClassName('author_info')[0],
		author_name = (author_hcid) ? author_hcid : post_block[i].getElementsByClassName('author')[0].firstElementChild.firstElementChild.innerHTML,
		stat_div = elem("table", "user_stats", ""),
		statUrl = [
			["<tr><td><a href='http://worldoftanks."+srv.srv+"/community/accounts/named/"+author_name+"' target='_blank'>Player Profile</a></td></tr>"],
			[srv.wl, "<tr><td><a target='_blank' href='http://wotlabs.net/"+srv.wl+"/player/"+author_name+"'>WoTLabs</a></td><tr>"],
			[srv.nm, "<tr><td><a target='_blank' href='http://noobmeter.com/player/"+srv.nm+"/"+author_name+"/'>Noobmeter</a></td><tr><tr>"],
			[srv.ws, "<tr><td><a target='_blank' href='http://www.wotstats.org/stats/"+srv.ws+"/"+author_name+"/'>WoTstats</a></td><tr>"],
			[srv.wlife, "<tr><td><a target='_blank' href='http://en.wot-life.com/"+srv.wlife+"/player/"+author_name+"/'>WoT-Life</a></td><tr>"],
			[srv.wr, "<tr><tr><td><a target='_blank' href='http://wotreplays."+srv.wr+"/player/"+author_name+"'>WoTReplays</a></td></tr><tr>"]
		];
		console.log(statUrl);
		for (var s=0; s<statUrl.length; ++s) {
			var uRow = document.createElement('tr');
			if (statUrl[s][0] && statUrl[s][1]) {
				uRow.appendChild(elem("td", "", statUrl[s][1]));
			}
			else {
				uRow.appendChild(elem("td", "", statUrl[s][0]));
			}
			stat_div.appendChild(uRow);
		}
		author_info.appendChild(stat_div);
}

// quick creation of element
function elem(tag, name, html, type) {
var element = document.createElement(tag);
	if (name) {element.className = name;}
	if (html) {element.innerHTML = html;}
	if (type) {element.type = type;}
	return element;
}

}());