Torn OC Role Evaluator

Evaluate OC roles based on influence and success chance

当前为 2025-07-12 提交的版本,查看 最新版本

// ==UserScript==
// @name         Torn OC Role Evaluator
// @namespace    underko.torn.scripts.oc
// @version      1.4
// @description  Evaluate OC roles based on influence and success chance
// @author       underko[3362751]
// @match        https://www.torn.com/factions.php*
// @grant        none
// @require      https://update.gf.qytechs.cn/scripts/502635/1422102/waitForKeyElements-CoeJoder-fork.js
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const influenceThresholds = {
        high: { good: 75, ok: 60 },
        medium: { good: 60, ok: 45 },
        low: { good: 40, ok: 30 }
    };

    const ocRoleInfluence = {
        "Mob Mentality": [
            { role: "Looter #1", influence: 34 },
            { role: "Looter #2", influence: 26 },
            { role: "Looter #4", influence: 23 },
            { role: "Looter #3", influence: 18 }
        ],
        "Pet Project": [
            { role: "Kidnapper", influence: 38 },
            { role: "Picklock", influence: 33 },
            { role: "Muscle", influence: 29 }
        ],
        "Cash Me If You Can": [
            { role: "Thief #1", influence: 50 },
            { role: "Lookout", influence: 28 },
            { role: "Thief #2", influence: 22 }
        ],
        "Best of the Lot": [
            { role: "Muscle", influence: 40 },
            { role: "Picklock", influence: 22 },
            { role: "Car Thief", influence: 20 },
            { role: "Imitator", influence: 17 }
        ],
        "Market Forces": [
            { role: "Enforcer", influence: 24 },
            { role: "Negotiator", influence: 22 },
            { role: "Muscle", influence: 20 },
            { role: "Lookout", influence: 15 },
            { role: "Arsonist", influence: 4 }
        ],
        "Smoke and Wing Mirrors": [
            { role: "Car Thief", influence: 50 },
            { role: "Imitator", influence: 24 },
            { role: "Hustler #2", influence: 17 },
            { role: "Hustler #1", influence: 9 }
        ],
        "Stage Fright": [
            { role: "Sniper", influence: 44 },
            { role: "Muscle #1", influence: 21 },
            { role: "Enforcer", influence: 17 },
            { role: "Muscle #3", influence: 10 },
            { role: "Lookout", influence: 7 },
            { role: "Muscle #2", influence: 2 }
        ],
        "Snow Blind": [
            { role: "Hustler", influence: 50 },
            { role: "Imitator", influence: 31 },
            { role: "Muscle #1", influence: 10 },
            { role: "Muscle #2", influence: 10 }
        ],
        "Leave No Trace": [
            { role: "Imitator", influence: 44 },
            { role: "Negotiator", influence: 30 },
            { role: "Techie", influence: 26 }
        ],
        "No Reserve": [
            { role: "Techie", influence: 46 },
            { role: "Engineer", influence: 39 },
            { role: "Car Thief", influence: 39 }
        ],
        "Honey Trap": [
            { role: "Muscle #2", influence: 43 },
            { role: "Muscle #1", influence: 32 },
            { role: "Enforcer", influence: 25 }
        ],
        "Bidding War": [
            { role: "Robber #3", influence: 28 },
            { role: "Robber #2", influence: 21 },
            { role: "Driver", influence: 18 },
            { role: "Bomber #2", influence: 16 },
            { role: "Bomber #1", influence: 9 },
            { role: "Robber #1", influence: 7 }
        ],
        "Blast from the Past": [
            { role: "Muscle", influence: 36 },
            { role: "Engineer", influence: 25 },
            { role: "Bomber", influence: 19 },
            { role: "Picklock #1", influence: 10 },
            { role: "Hacker", influence: 9 },
            { role: "Picklock #2", influence: 2 }
        ],
        "Break the Bank": [
            { role: "Muscle #3", influence: 25 },
            { role: "Thief #2", influence: 24 },
            { role: "Robber", influence: 21 },
            { role: "Muscle #1", influence: 19 },
            { role: "Muscle #2", influence: 7 },
            { role: "Thief #1", influence: 5 }
        ],
        "Stacking the Deck": [
            { role: "Imitator", influence: 42 },
            { role: "Cat Burglar", influence: 29 },
            { role: "Hacker", influence: 25 },
            { role: "Driver", influence: 4 }
        ],
        "Ace in the Hole": [
            { role: "Hacker", influence: 36 },
            { role: "Driver", influence: 23 },
            { role: "Muscle #2", influence: 16 },
            { role: "Muscle #1", influence: 15 },
            { role: "Imitator", influence: 9 }
        ]
    };

    let crimeData = {};
    let previousTab = "none";

    function classifyOcRoleInfluence(ocName, roleName, successChance) {
        const roleData = ocRoleInfluence[ocName]?.find(r => r.role === roleName);
        const influence = roleData ? roleData.influence : 0;

        let thresholds;

        if (influence >= 30) thresholds = influenceThresholds.high;
        else if (influence >= 10) thresholds = influenceThresholds.medium;
        else thresholds = influenceThresholds.low;

        if (successChance >= thresholds.good) return { evaluation: 'good', influence };
        if (successChance >= thresholds.ok) return { evaluation: 'ok', influence };
        return { evaluation: 'bad', influence };
    }

    function processCrime(wrapper) {
        const ocId = wrapper.getAttribute('data-oc-id');
        if (!ocId || crimeData[ocId]) return;

        const titleEl = wrapper.querySelector('p.panelTitle___aoGuV');
        if (!titleEl) return;

        const crimeTitle = titleEl.textContent.trim();
        const roles = [];

        const roleEls = wrapper.querySelectorAll('.title___UqFNy');
        roleEls.forEach(roleEl => {
            const roleName = roleEl.textContent.trim();
            const successEl = roleEl.nextElementSibling;
            const chance = successEl ? parseInt(successEl.textContent.trim(), 10) : null;
            const evaluation = chance !== null ? classifyOcRoleInfluence(crimeTitle, roleName, chance) : { evaluation: 'unknown', influence: null };
            roles.push({ role: roleName, chance, evaluation });

            if (successEl && evaluation.influence !== null) {
                successEl.textContent = `${chance}/${evaluation.influence}`;
            }

            const slotHeader = roleEl.closest('button.slotHeader___K2BS_');
            if (slotHeader) {
                switch (evaluation.evaluation) {
                    case 'good':
                        slotHeader.style.backgroundColor = '#239b56'; break;
                    case 'ok':
                        slotHeader.style.backgroundColor = '#ca6f1e'; break;
                    case 'bad':
                        slotHeader.style.backgroundColor = '#a93226'; break;
                }
            }
        });

        crimeData[ocId] = { id: ocId, title: crimeTitle, roles };
    }

    function setupMutationObserver(root) {
        const observer = new MutationObserver(() => {
            const tabTitle = document.querySelector('button.active___ImR61 span.tabName___DdwH3')?.textContent.trim();

            if (tabTitle !== 'Recruiting' && tabTitle !== 'Planning') return;

            if (previousTab !== tabTitle) {
                crimeData = {};
                previousTab = tabTitle;
            }

            const allCrimes = document.querySelectorAll('.wrapper___U2Ap7');
            allCrimes.forEach(crimeNode => {
                processCrime(crimeNode);
            });
        });

        observer.observe(root, { childList: true, subtree: true });
    }

    waitForKeyElements("#faction-crimes-root", (root) => {
        setupMutationObserver(root);
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址