Skip to content

Instantly share code, notes, and snippets.

@DenimTornado
Created June 8, 2018 11:36
Show Gist options
  • Save DenimTornado/d8dbe9dc23c5a086124acfd6803f1b4c to your computer and use it in GitHub Desktop.
Save DenimTornado/d8dbe9dc23c5a086124acfd6803f1b4c to your computer and use it in GitHub Desktop.
Stats parser for FM
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo
// @grant none
// ==/UserScript==
$(function( ) {
var table = ('.compare-players-table');
var strings = $(table).find('tr');
var stats = {};
for(var i = 0; i < strings.length; i++) {
var tr = $(strings[i]);
var name = $(tr).find('th')[0];
// console.log($(name));
if (!!$(name).text()) {
var bstat = $(strings[i]).find('.text-left');
var stat = $(bstat[0]).find('b');
stats[$(name).text()] = $(stat[0]).html();
}
}
var div = $('<div id="statsPop"></div>');
$(div).css( "position", "absolute" );
$(div).css( "background-color", "#fff" );
$(div).css( "top", "60px" );
$(div).css( "left", "0" );
$(div).css( "z-index", "10" );
$(div).css( "padding", "10px" );
var table2 = $('<table></table>');
var statsArrr = [
"Acceleration",
"Aggression",
"Awareness",
"Ball Control",
"Crossing",
"Dribbling",
"Heading",
"Long Passing",
"Marking",
"Sprint Speed",
"Short Passing",
"Reflexes",
"Finishing",
"Shot Power",
"",
"Strength",
"Tackling",
"",
"",
"",
"Positioning",
"",
"",
"",
"",
"Composure",
"Handling",
"GK Positioning",
"Reactions",
"Long Shots",
"Free Kick Accuracy",
"GK Diving"
];
for (var j = 0; j < statsArrr.length; j++) {
if (!!stats[statsArrr[j]]) {
$(table2).append('<tr><td>'+stats[statsArrr[j]]+'</td><td>'+statsArrr[j]+'</td></tr>');
} else {
$(table2).append('<tr><td></td><td>?</td></tr>');
}
}
$(div).append(table2);
$('body').append(div);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment