virtualmanager.com - Employee show stars and role

Shows stars and role on employeesearch

目前为 2023-01-13 提交的版本。查看 最新版本

// ==UserScript==
// @name         virtualmanager.com - Employee show stars and role
// @namespace    https://greasyfork.org/en/users/884999-l%C3%A6ge-manden
// @version      0.4
// @description  Shows stars and role on employeesearch
// @author       VeryDoc
// @match        https://www.virtualmanager.com/employees/search?*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=virtualmanager.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';
let myTable = document.getElementsByTagName("table")[0].getElementsByTagName('tbody')[0];

    let rows = myTable.rows;

    for (let row of rows) {
        if (row.classList.contains('toprow')) {
            let newCell = row.insertCell();
            let newText = document.createTextNode('Ability');
            newCell.appendChild(newText);

            newCell = row.insertCell();
            newText = document.createTextNode('Speciality');
            newCell.appendChild(newText);
        } else {
            let a = row.cells[7];
            let skillstable = a.getElementsByTagName("table")[0].getElementsByTagName('tbody')[0];
            let skills = skillstable.children;
            let youthSkills = parseInt(skills[0].innerText.trim().replace('                                ', '').replace('\n', ':').split(':')[1]);
            let goalkeepingSkills = parseInt(skills[1].innerText.trim().replace('                                ', '').replace('\n', ':').split(':')[1]);
            let fieldplayerSkills = parseInt(skills[2].innerText.trim().replace('                                ', '').replace('\n', ':').split(':')[1]);
            let disiplinSkills = parseInt(skills[3].innerText.trim().replace('                                ', '').replace('\n', ':').split(':')[1]);
            let motivationSkills = parseInt(skills[7].innerText.trim().replace('                                ', '').replace('\n', ':').split(':')[1]);

            let totalSkills = youthSkills + goalkeepingSkills + fieldplayerSkills + disiplinSkills + motivationSkills;
            let newCell = row.insertCell();

            let newText = document.createTextNode('⭐');

            switch (true) {
                case (totalSkills > 80):
                    newText = document.createTextNode('⭐⭐⭐⭐⭐');
                    break;
                case (totalSkills > 60 && totalSkills < 80):
                    newText = document.createTextNode('⭐⭐⭐⭐');
                    break;
                case (totalSkills > 40 && totalSkills < 60):
                    newText = document.createTextNode('⭐⭐⭐');
                    break;
                case (totalSkills > 20 && totalSkills < 40):
                    newText = document.createTextNode('⭐⭐');
                    break;
            }

            newCell.appendChild(newText);

            let coachString = "";

            if (disiplinSkills > motivationSkills) {
                coachString += "Yelling ";
            } else {
                coachString += "Motivating ";
            }

            if (youthSkills > 10) {
                coachString += "youth ";
            } else {
                coachString += "senior ";
            }

            if (fieldplayerSkills > goalkeepingSkills) {
                coachString += "field";
            } else {
                coachString += "goalkeeper";
            }

            newCell = row.insertCell();
            newCell.style.fontSize = "9px";
            newText = document.createTextNode(coachString);
            newCell.appendChild(newText);
        }
    };
})();