Mark Scamming Pips

Mark every 10th pip in the Scamming crime. Quick and dirty GPT special.

当前为 2024-08-31 提交的版本,查看 最新版本

// ==UserScript==
// @name         Mark Scamming Pips
// @namespace    https://torn.report/userscripts/
// @version      0.3
// @description  Mark every 10th pip in the Scamming crime. Quick and dirty GPT special.
// @author       Skeletron [318855]
// @match        https://www.torn.com/loader.php?sid=crimes
// @icon         https://www.google.com/s2/favicons?sz=64&domain=torn.com
// @license      GNU GPLv3
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to process each persuasion bar
    function processPersuasionBar(persuasionBar) {
        // Get all cells within the persuasion bar, including nested ones
        const cells = persuasionBar.getElementsByClassName('cell___AfwZm');

        // Iterate through the cells and insert "X" in every 10th cell if it hasn't been added yet
        for (let i = 9; i < cells.length; i += 10) {
            if (!cells[i].textContent.includes('|')) {
                cells[i].textContent += '|';
                cells[i].style.textAlign = 'center';
            }
        }
    }

    // Function to handle mutations
    function handleMutations(mutationsList) {
        for (const mutation of mutationsList) {
            if (mutation.type === 'childList') {
                // Check if any new persuasion bars were added
                const newPersuasionBars = mutation.target.getElementsByClassName('persuasionBar___RnWKh');
                Array.from(newPersuasionBars).forEach(processPersuasionBar);
            }
        }
    }

    // Set up the MutationObserver to watch the entire document
    const observer = new MutationObserver(handleMutations);
    observer.observe(document.body, { childList: true, subtree: true });

})();