Mark Scamming Pips

Mark pips in the Scamming crime. Quick and dirty GPT special.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Mark Scamming Pips
// @namespace    https://torn.report/userscripts/
// @version      0.4
// @description  Mark pips 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==

const addTenthPipMark = true;
const addPipBorder = false;
const addPipNumbers = false; // Only good for desktop.

(function () {
  "use strict";

  function addBeforePersuasionBar(persuasionBar) {
    if (
      !persuasionBar.previousElementSibling ||
      !persuasionBar.previousElementSibling.classList.contains(
        "custom-inserted-div"
      )
    ) {
      const numbersDiv = document.createElement("div");
      numbersDiv.style.fontFamily = "monospace";
      numbersDiv.style.fontSize = "0.795rem";
      numbersDiv.style.position = "absolute";
      numbersDiv.style.bottom = "-11px";
      numbersDiv.textContent =
        "12345678901234567890123456789012345678901234567890";
      numbersDiv.classList.add("custom-inserted-div");

      persuasionBar.parentNode.insertBefore(numbersDiv, persuasionBar);
    }
  }

  // Function to process each persuasion bar
  function processPersuasionBar(persuasionBar) {
    // Add the new div before the persuasion bar
    addPipNumbers && addBeforePersuasionBar(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 = 0; i < cells.length; i++) {
      const cell = cells[i];

      // Apply the border to every cell
      addPipBorder &&
        (cell.style.borderLeft = "1px dotted var(--crimes-subText-color)");

      // Add '|' to every 10th cell
      if (addTenthPipMark && i !== 49 && i % 10 === 9) {
        if (!cell.textContent.includes("|")) {
          cell.textContent += "|";
        }
        cell.style.textAlign = "center"; // Set text alignment only for the cells with '|'
      }
    }
  }

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

  const crimesApp = document.querySelector(".crimes-app");
  if (crimesApp) {
    const observer = new MutationObserver(handleMutations);
    observer.observe(crimesApp, { childList: true, subtree: true });
  }
})();