Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let highest_percentage = {value: 0, name: ""}
- const PLAYERS_MAX = 11
- let current_checked_players = 0
- let observer = new MutationObserver(function (mutations) {
- mutations.forEach(function (mutation) {
- if (mutation.addedNodes.length) {
- player_properties(mutation.addedNodes[0])
- }
- })
- })
- Array.from(document.getElementsByTagName("tr"))
- .filter(function(a) {
- let tds = Array.from(a.children)
- return a.id && tds.length > 1 && tds[1].className && tds[1].className !== "posSUB";
- })
- .forEach(function(tr) {
- let id = tr.id.match(/[0-9]+/g)[0]
- let properties = document.querySelector('#td_id_Player' + id)
- let properties_table = properties.querySelector("table")
- if (!properties_table) {
- observer.observe(properties, {
- childList: true
- });
- getPlayer(id, 'id_Player')
- } else {
- player_properties(properties_table)
- }
- })
- function player_properties(node) {
- let jersey_name = document.querySelector("#trPlayer" + node.parentNode.id.match(/[0-9]+/g)[0]).children[1].innerText
- let name = jersey_name.match(/[0-9]+\. (.+)/)[1]
- let percentage = parseInt(node.getElementsByTagName("td")[2].innerText)
- if (percentage > highest_percentage["value"]) {
- highest_percentage["value"] = percentage
- highest_percentage["name"] = name
- }
- current_checked_players += 1
- if (current_checked_players === PLAYERS_MAX) {
- console.log("Captain should be " + highest_percentage["name"] + " (" + highest_percentage["value"] + "%)");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement