Last active
August 30, 2016 07:49
-
-
Save firebotQL/a4e1821e66a3b5fa30b4 to your computer and use it in GitHub Desktop.
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 match ranks | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Shows elo and level of player in match screen. | |
// @author Viaceslavas 'fire_bot' Duk | |
// @match https://beta.faceit.com/en/csgo/room* | |
// @grant none | |
// ==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
angular.element(document).ready(function() { | |
// NOTE: if anyone knows how to plug in into angularjs controller to $watch when "members" has changed/loaded then | |
// we can get rid of setTimeout and all html scraping boilerplate(and maybe 10 get calls?) please let know. Thanks! | |
setTimeout(function(){ | |
var matchItems = $(".match-team-member .match-team-member__row"); | |
$(".match-vs .match-team-member__row .match-team-member__name").each(function(idx, el) { | |
var href = $(el).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 ) { | |
//debugger; | |
var csgoPayload = data['payload']['games']['csgo']; | |
var resultHTML = "<div class='match-team-member__row__item'>"; | |
resultHTML += "<div class='pa-sm'>Level: " + csgoPayload['csgo_skill_level'] + " ELO: <strong>" + csgoPayload['faceit_csgo_elo'] + "</strong></div>"; | |
resultHTML += "</div>"; | |
$(matchItems[idx]).append(resultHTML); | |
}); | |
} | |
} | |
}); | |
}, 3000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment