Das' OC checker

adds color highlights to OCs where members do not fulfill the success chance requirements

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Das' OC checker
// @version      0.1
// @namespace    https://github.com/DasLewis
// @description  adds color highlights to OCs where members do not fulfill the success chance requirements
// @icon         https://www.google.com/s2/favicons?sz=64&domain=torn.com
// @author       DasLewis [2524294]
// @license      MIT License
// @match        https://www.torn.com/factions.php*
// @grant        none
// ==/UserScript==
//DISCLAIMER: THIS SCRIPT USES SOME APPROACHES FROM "Torn Pickpocketing Colors" by Korbrm [2931507]
//https://greasyfork.org/en/scripts/477536-torn-pickpocketing-colors


(function() {
    'use strict';
    const scriptPrefix = "Das_OC_checker";
    const colorCodeBad = "#B22222";

    //success chance required for each OC level
    const ocRequirements = {
        "1" : 80,
        "2" : 80,
        "3" : 80,
        "4" : 80,
        "5" : 80,
        "6" : 80,
        "7" : 70,
        "8" : 60,
        "9" : 80,
        "10" : 80
    };

    function updateOCMarkers() {
        const url = window.location.href;
        if (!url.includes("#/tab=crimes")){
            return;
        }

        const ocElements = document.querySelectorAll('.wrapper___U2Ap7:not(.processed)');
        ocElements.forEach(ocElement => {
            const ocLevel = ocElement.querySelector('.levelValue___TE4qC').textContent.trim();
            const ocName = ocElement.querySelector('.panelTitle___aoGuV').textContent.trim();
            const ocParticipants = ocElement.querySelectorAll('.wrapper___Lpz_D');
            ocParticipants.forEach(participantWrapper => {
                if (!participantWrapper.classList.contains("waitingJoin___jq10k")) {
                    const participantSuccess = participantWrapper.querySelector('.successChance___ddHsR').textContent.trim();
                    const participantName = participantWrapper.querySelector('.badge___E7fuw').querySelectorAll('.honor-text')[1].textContent.trim();
                    if (ocRequirements[ocLevel] > participantSuccess) {
                        //console.log(`User "${participantName}" in OC "${ocName}" (Level ${ocLevel}) does not meet requirements. (${participantSuccess}/${ocRequirements[ocLevel]})`);
                        ocElement.querySelector('.wrapper___eWVgj').style.backgroundColor = colorCodeBad;
                        participantWrapper.querySelector('.slotHeader___K2BS_').style.backgroundColor = colorCodeBad;
                    }
                }
            })

            ocElement.classList.add('processed');
        });
    }

    updateOCMarkers();
    setInterval(updateOCMarkers, 1000);
})();