"+loc.p60+""+loc.p61+""),
vehicles_h3_class = vehTable_class.previousElementSibling.previousElementSibling;
vehicles_h3_class.className = "b-profile-ratings_title";
vehiclesHeader_div.insertBefore(vehicles_h3_class, vehiclesHeader_div.firstChild);
vehicles_div.appendChild(vehiclesHeader_div);
vehTable_class.parentNode.insertBefore(vehicles_div, vehTable_class);
vehicles_div.appendChild(vehTable_class);
// add a premium tanks table to the vehicle table
var premHBody = document.createElement('tbody'),
premTBody = document.createElement('tbody');
vehTable_class.appendChild(premHBody);
if (premArr.length === 0) {
premHBody.appendChild(elem("tr", "t-profile_tankstype t-profile_tankstype-prem t-profile_tankstype__empty", "| "+loc.p62+" | – | – | – | | "));
}
else {
premHBody.className = "tablesorter-no-sort";
premHBody.appendChild(elem("tr", "t-profile_tankstype t-profile_tankstype-prem js-table-dropdown-link", ""+loc.p62+" "+premArr.length+" | "+filter(s.s.p.b,2)+" | "+colStat((s.s.p.w/s.s.p.b)*100, "wrv", 0, "%")+""+filter(s.s.p.w,2)+" | "+s.s.p.bg+" | | "));
premTBody.className = "sortable";
premTBody.style.display="none";
vehTable_class.appendChild(premTBody);
for (var i=0; i✖"+loc.p68+" – | – | – | | "));
}
else {
tenHBody.className = "tablesorter-no-sort";
tenHBody.appendChild(elem("tr", "t-profile_tankstype js-table-dropdown-link", "✖"+loc.p68+" "+tenArr.length+" | "+filter(s.s.t.b,2)+" | "+colStat((s.s.t.w/s.s.t.b)*100, "wrv", 0, "%")+""+filter(s.s.t.w,2)+" | "+s.s.t.bg+" | | "));
tenTBody.className = "sortable";
tenTBody.style.display="none";
vehTable_class.appendChild(tenTBody);
for (var i=0; i"+loc.p65+"";
}
// end tableBattles
}
// end wg.player
// matches url with clan page
else if (wg.clans) {
// getting claninfo
wg.clan.id = wg.href.match(/\/(\d+)/)[1];
wg.clan.name = document.getElementsByClassName('js-clan-tag')[0].innerHTML.match(/[\w.+\-]+/)[0];
// style contents
style.innerHTML
= ".b-scriptlink {font-size: 12px; padding: 6px 10px 5px;}"
+ ".clan_info {display: inline-block; margin-left: 18px; max-width: 500px;}"
+ ".clan-links {float: right; display: inline-block;}"
+ ".clan-links li.statname {margin: 0;}"
+ ".clan-links li {margin-left: 10px;}"
+ "";
// end style
// script link
var clanHead_div = elem("li", "global-nav__item", sc.link),
navService_class = document.getElementsByClassName('global-nav__service')[0];
navService_class.insertBefore(clanHead_div, navService_class.firstChild);
// script link
var menu_class = document.getElementsByClassName('js-menu')[2],
menuNick = menu_class.getElementsByTagName('a')[0].innerHTML.match(/(\w)+/)[0],
menuLink = elem("li", "global-nav__submenu-item", "My Profile");
menu_class.getElementsByTagName('ul')[0].insertBefore(menuLink, menu_class.getElementsByTagName('ul')[0].firstChild);
// clan statistic links
var clan_class = document.getElementsByClassName('clan')[1],
clanStat_list = elem("ul", "clan-links", ""),
clanUrl = [
[loc.p66],
[srv.wl, "WoTLabs"],
[srv.nm, "Noobmeter"],
[srv.wn, "Wot-news"],
[srv.cs, "WoT-CS"],
[srv.wlife, "WoT-Life"],
[loc.p67],
[srv.wr, "WoTReplays"]
];
linksHnd(clanStat_list, clanUrl, "list");
clan_class.appendChild(clanStat_list);
}
// end wg.clans
// helper functions
// filter
function filter(input, type) {
var inputStr = input.toString();
switch(type) {
case (1): // input string into number
return parseFloat(inputStr.replace(/[^\d]/g,""));
case (2): // output number with locale symbol
return inputStr.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1"+loc.sym);
case (3): // remove all symbols
return inputStr.replace(/[^\w]/g,"");
default:
console.error("Error filtering: ", input);
return input;
}
}
// colouring
function colStat(input, type, dec, sym, ext) {
var color = colArr.dft.col,
output = input.toFixed(dec);
if (sym) {
output += sym;
}
else if (type == "bat") {
output = filter(input,2);
}
else if (type == "dmg") {
output = filter(ext.toFixed(0),2);
}
if (type !== "") {
if (s.col[type]) {
color = s.col[type];
}
else if (type == "wrv") {
type = "wr";
for (var x in colArr) {
if (colArr.hasOwnProperty(x)) {
if (input >= colArr[x][type]) {
color = colArr[x].col;
break;
}
}
}
}
else {
for (var x in colArr) {
if (colArr.hasOwnProperty(x)) {
if (input >= colArr[x][type]) {
color = colArr[x].col;
break;
}
}
}
s.col[type] = color;
}
}
return ""+output+"";
}
// 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;
}
// quick insertion of row into tables
function elemRow(parent, text_td, val_td, val2_td) {
var trNew = document.createElement('tr'),
tdNew_text = elem("td", "t-dotted_minor", text_td),
tdNew_value = elem("td", "t-dotted_value", val_td);
trNew.appendChild(tdNew_text);
trNew.appendChild(tdNew_value);
if (parent == mb_table) {
tdNew_text.className = "t-dotted_class-ico t-dotted_minor__middle";
tdNew_value.className = "t-dotted_minor t-dotted_minor__middle";
}
if (val2_td !== "") {
var tdNew_value2 = elem("td", "t-dotted_value", val2_td);
if (parent == mb_table) {
tdNew_value2.className = "t-dotted_value t-dotted_minor__middle";
}
trNew.appendChild(tdNew_value2);
}
parent.appendChild(trNew);
return trNew;
}
// links handler
function linksHnd(parent, links, type) {
for (var i=0; iWoTLabs"],
[srv.nm, "Noobmeter"],
[srv.wn, "Wot-news"]
],
[
[""],
[srv.cs, "WoT-CS"],
[srv.wlife, "WoT-Life"]
],
[
[loc.p67],
[srv.wr, "WoTReplays"]
]
];
clanStat_table.id = "js-profile-clan-table";
linksHnd(clanStat_table, clanUrl, "table");
cc_class.appendChild(clanStat_table);
profileName_class.parentNode.insertBefore(cc_class, profileName_class.nextSibling);
clearInterval(cc_classChecker);
}
else if (cc_classCheckSeq == 5 || ct_class !== null) {
clearInterval(cc_classChecker);
}
}, 1500);
}
// noobmeter handler
function nmHnd(response) {
if (response.statusText == "OK" && !isNaN(parseFloat(response.responseText))) {
nmHnd_insert(parseFloat(response.responseText));
}
else {
nmHnd_error();
}
}
function nmHnd_error() {
nmHnd_insert(loc.p75);
console.error("Error accessing NoobMeter API");
}
function nmHnd_insert(nm) {
var ratingsInfo_div = document.getElementsByClassName('js-noobmeter')[1],
ratingsClip_div = document.getElementsByClassName('js-noobmeter')[0];
if (!isNaN(nm)) {
ratingsInfo_div.innerHTML = colStat(nm,"nm",2);
ratingsClip_div.innerHTML += " NM: "+nm.toFixed(2);
}
else {
ratingsInfo_div.innerHTML = nm;
}
}
// end noobmeter handler
// clan history handler
function chHnd(response) {
if (response.statusText == "OK") {
chHnd_insert(JSON.parse(response.responseText).changes);
}
else {
chHnd_error();
}
}
function chHnd_error() {
clanHist_div.appendChild(elem("span", "", loc.p77));
console.error("Error accessing WoT-CS API");
}
function chHnd_insert(ch) {
var prevClan, clanHist_span;
if (ch.length > 0) {
for (var i=0; i["+ch[i].clan_tag+"]");
clanHist_div.insertBefore(clanHist_span, clanHist_div.firstChild.nextSibling);
}
prevClan = ch[i].clan_tag;
}
}
else {
clanHist_div.appendChild(elem("span", "clantag", loc.p76));
}
}
// end clan history handler
// retrieval function
function gRec(doc) {
GM_xmlhttpRequest({
method: "GET",
url: doc.url,
headers: {
"Accept": "text/xml"
},
onload: function(resp) {
if (resp.readyState == 4) {
if (resp.status == 200) {
doc.handler(resp);
}
}
},
onerror: function() {
doc.onerror();
}
});
}
// global functions inserted into head
// clipboard helper
function copyClipboard() {
var cpText = document.getElementsByClassName('ratingsClip-holder')[0].innerHTML,
cpLoc = document.getElementsByClassName('ratingsClip-holder')[1].innerHTML;
window.prompt(cpLoc, cpText);
}
// end global functions
}());