Show stars and role

Shows stars and role on employeesearch

目前为 2022-10-12 提交的版本。查看 最新版本

// ==UserScript==
// @name         Show stars and role
// @namespace    https://greasyfork.org/en/users/884999-l%C3%A6ge-manden
// @version      0.2
// @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];
            a.style.width = "16px";
            a = a.children[0];
            a = a.children[1];

            let skills = a.onmouseover.toString();
            skills = skills.replace('function onmouseover(event) {', '');
            skills = skills.replace('}', '');
            skills = skills.replace(');', '');
            skills = skills.replace('view_stats(', '');

            skills = skills.trim();
            skills = skills.split(', ');

            let youthSkills = parseInt(skills[1]);
            let goalkeepingSkills = parseInt(skills[2]);
            let fieldplayerSkills = parseInt(skills[3]);
            let disiplinSkills = parseInt(skills[4]);
            let motivationSkills = parseInt(skills[8]);

            let totalSkills = youthSkills + goalkeepingSkills + fieldplayerSkills + disiplinSkills + motivationSkills;
            console.log(totalSkills);
            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);
        }
    };
})();