Forked from firebotQL/faceit-elo-level-script.js
Last active
August 30, 2016 14:20
-
-
Save BONNe/da8902e4a663341a312a46c757ec2a8e to your computer and use it in GitHub Desktop.
Faceit Elo Level script for each game.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name FaceIT WOT match ranks | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Shows elo and player WN8 rank | |
// @author BONNe | |
// @match https://www.faceit.com/en/* | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
angular.element(document).ready(function() { | |
setTimeout(function(){ | |
var matchItems = $(".match-team-member .match-team-member__details__name"); | |
matchItems.each(function(idx, el) { | |
var href = $(el.getElementsByTagName("a")[0]).attr("href"); | |
if (href) { | |
var splitHref = href.split("/"); | |
var nickIdx = splitHref.length-1; | |
if (splitHref[nickIdx]) { | |
$.get("https://api.faceit.com/api/nicknames/" + splitHref[nickIdx], function( data ) { | |
var game = window.location.href.split('/')[4]; | |
var playload = data['payload']['games'][game]; | |
var skill = playload['faceit_elo']; | |
var color = getLeagueColor(game, skill); | |
var flag = getFlag(data['payload']['country']); | |
var userLink = getUserLink(game, playload); | |
var resultHTML = "<div class='match-team-member_custom_info'>"; | |
resultHTML += "<div class='name-" + playload['game_id'] + "'>Ingame name: " + flag + " </div>"; | |
resultHTML += "<div class='rank'>"; | |
resultHTML += "ELO: <strong style='color: " + color + "'>" + playload['faceit_elo'] + "</strong>"; | |
resultHTML += "<span class='wg-" + playload['game_id'] + "'></span></div>"; | |
resultHTML += "</div>"; | |
$(matchItems[idx]).append(resultHTML); | |
}); | |
} | |
} | |
}); | |
}, 3000); | |
}); | |
function getLeagueColor(game, skill) { | |
var color = "grey"; | |
switch (game) | |
{ | |
case "wot_EU": | |
color = "#912600"; | |
if (skill > 1099) color = "silver"; | |
if (skill > 1499) color = "gold"; | |
if (skill > 1849) color = "#b9f2ff"; | |
if (skill > 1949) color = "orange"; | |
break; | |
case "wot_RU": | |
color = "#912600"; | |
if (skill > 1099) color = "silver"; | |
if (skill > 1499) color = "gold"; | |
if (skill > 1849) color = "#b9f2ff"; | |
if (skill > 1949) color = "orange"; | |
break; | |
case "wot_NA": | |
color = "#912600"; | |
if (skill > 1099) color = "silver"; | |
if (skill > 1499) color = "gold"; | |
if (skill > 1849) color = "#b9f2ff"; | |
if (skill > 1949) color = "orange"; | |
break; | |
default: | |
if (skill > 800) color = "green"; | |
if (skill > 1100) color = "gold"; | |
if (skill > 1700) color = "orange"; | |
if (skill > 2000) color = "red"; | |
} | |
return color; | |
} | |
function wgColor(skill) | |
{ | |
var color = "black"; | |
if (skill > 2020) color = "#cd3333"; | |
if (skill > 4185) color = "#d7b600"; | |
if (skill > 6340) color = "#6d9521"; | |
if (skill > 8525) color = "#4a92b7"; | |
if (skill > 9930) color = "#83579d"; | |
return color; | |
} | |
function getFlag(country) | |
{ | |
return "<img src='https://flags.fmcdn.net/data/flags/small/" + country + ".png' alt='" + country + " Flag' height='12' width='12' />"; | |
} | |
function getUserLink(game, data){ | |
var userID = data['game_id']; | |
switch (game) | |
{ | |
case "wot_EU": | |
$.ajax({ | |
url: 'https://api.worldoftanks.eu/wot/account/info/?application_id=c3b3e8c9b7c294ff52b43396b83384a9&account_id=' + userID, | |
type: 'GET', | |
timeout: 30000, | |
error: function(){ | |
return true; | |
}, | |
success: function(json){ | |
var username = json['data'][userID]['nickname']; | |
var wgrating = json['data'][userID]['global_rating']; | |
var text = $(".name-" + userID); | |
$(text).append("<a href='http://worldoftanks.eu/en/community/accounts/" + userID + "-" + username + "/' >" + username + "</a>"); | |
var text2 = $(".wg-" + userID); | |
$(text2).append(" WG Rating: <strong style='color:" + wgColor(wgrating) +"'>" + wgrating + "</strong>"); | |
} | |
}); | |
break; | |
case "wot_RU": | |
$.ajax({ | |
url: 'https://api.worldoftanks.ru/wot/account/info/?application_id=c3b3e8c9b7c294ff52b43396b83384a9&account_id=' + userID, | |
type: 'GET', | |
timeout: 30000, | |
error: function(){ | |
return true; | |
}, | |
success: function(json){ | |
var username = json['data'][userID]['nickname']; | |
var wgrating = json['data'][userID]['global_rating']; | |
var text = $(".name-" + userID); | |
$(text).append("<a href='http://worldoftanks.ru/ru/community/accounts/" + userID + "-" + username + "/' >" + username + "</a>"); | |
var text2 = $(".wg-" + userID); | |
$(text2).append(" WG Rating: <strong style='color:" + wgColor(wgrating) +"'>" + wgrating + "</strong>"); | |
} | |
}); | |
break; | |
case "wot_NA": | |
$.ajax({ | |
url: 'https://api.worldoftanks.com/wot/account/info/?application_id=c3b3e8c9b7c294ff52b43396b83384a9&account_id=' + userID, | |
type: 'GET', | |
timeout: 30000, | |
error: function(){ | |
return true; | |
}, | |
success: function(json){ | |
var username = json['data'][userID]['nickname']; | |
var wgrating = json['data'][userID]['global_rating']; | |
var text = $(".name-" + userID); | |
$(text).append("<a href='http://worldoftanks.com/en/community/accounts/" + userID + "-" + username + "/' >" + username + "</a>"); | |
var text2 = $(".wg-" + userID); | |
$(text2).append(" WG Rating: <strong style='color:" + wgColor(wgrating) +"'>" + wgrating + "</strong>"); | |
} | |
}); | |
break; | |
default: | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment