Skip to content

Instantly share code, notes, and snippets.

@DenimTornado
Created June 8, 2018 20:39
Show Gist options
  • Save DenimTornado/8c769e0573ded6c88a85fe911f1406c2 to your computer and use it in GitHub Desktop.
Save DenimTornado/8c769e0573ded6c88a85fe911f1406c2 to your computer and use it in GitHub Desktop.
Stats parser for FM New scheme
// ==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"
];
var stat1 = '';
var stat2 = '';
var stat3 = '';
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>');
}
if (j < 8) {
if (!!stats[statsArrr[j]]) {
if (stat1.length > 0) {
stat1 = stat1 + ';' + stats[statsArrr[j]];
} else {
stat1 = stat1 + stats[statsArrr[j]];
}
}
}
if (j >= 8 && j < 17) {
if (!!stats[statsArrr[j]]) {
if (stat2.length > 0) {
stat2 = stat2 + ';' + stats[statsArrr[j]];
} else {
stat2 = stat2 + stats[statsArrr[j]];
}
}
}
if (j > 19) {
if (!!stats[statsArrr[j]]) {
if (stat3.length > 0) {
stat3 = stat3 + ';' + stats[statsArrr[j]];
} else {
stat3 = stat3 + stats[statsArrr[j]];
}
}
}
}
var playerName = $('.card-col')[1];
playerName = $(playerName).find('b')[0];
playerName = $(playerName).html();
var script = "edit('"+stat1+"::29')</br>" +
"edit('"+stat2+"::33')</br>" +
"edit('"+stat3+"::45')</br>";
$(div).append('--' + playerName + '</br>');
$(div).append(script);
$(div).append('----------------</br>');
$(div).append(table2);
$('body').append(div);
console.log(script);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment