Skip to content

Commit

Permalink
added function to get best suitable roles from fminside
Browse files Browse the repository at this point in the history
  • Loading branch information
moth1995 committed Nov 16, 2023
1 parent 192a18f commit 8b80cc0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions js/fminside_player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class FMInsidePlayer{
this.doc = doc;
this.GetBasicInfo();
this.GetStats();
this.GetRoles();
}

GetBasicInfo(){
Expand Down Expand Up @@ -69,6 +70,25 @@ class FMInsidePlayer{
console.log(this.stats);
}

GetRoles(){
var roles = {};
try{
const rolesLis = this.doc.querySelector('#player > div:nth-child(4)').querySelector('ol').querySelectorAll('li:not(.last)');
rolesLis.forEach(function(li){
var key = li.querySelector("span.key").textContent;
var valueElement = li.querySelector("span.value");
var value = valueElement.textContent;
roles[key] = parseFloat(value);
})
}
catch(err){
console.log(err);
console.log("No roles found");
}
this.roles = roles;
console.log(this.roles);
}

}

// create button element
Expand Down

0 comments on commit 8b80cc0

Please sign in to comment.