virtualmanager.com - Employee show stars and role

Shows stars and role on employeesearch

当前为 2023-01-13 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
        }
    };
})();